fix changing locale breaking everything yay
This commit is contained in:
parent
e31246c892
commit
387d58dfa2
7 changed files with 53 additions and 25 deletions
|
@ -1,7 +1 @@
|
|||
import 'package:http/http.dart' as http;
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:oauth2/oauth2.dart' as oauth2;
|
||||
|
||||
// Future<http.Client> authorize({required String userid}) {
|
||||
// }
|
||||
|
|
9
lib/i18n/de_DE.json
Normal file
9
lib/i18n/de_DE.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"greeting": "hallo!",
|
||||
"user-id-not-valid": "Hmm... die id sieht nicht ganz richtig aus...",
|
||||
"user-id": "nutzer id",
|
||||
"user-id-example": "nutzer@beispiel.de",
|
||||
"authorize-in-browser": "im browser autorisieren",
|
||||
"login-failed-snackbar-text": "login fehlgeschlagen!"
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
"user-id-not-valid": "Sorry, this user id doesn't look quite right... ",
|
||||
"user-id": "user id",
|
||||
"user-id-example": "user@example.com",
|
||||
"authorize-in-browser": "authorize in browser"
|
||||
"authorize-in-browser": "authorize in browser",
|
||||
"login-failed-snackbar-text": "login failed!"
|
||||
}
|
||||
|
|
@ -2,12 +2,31 @@ import 'package:flutter/material.dart';
|
|||
import 'package:localization/localization.dart';
|
||||
import 'package:slothmu/partials/main_scaffold.dart';
|
||||
import 'pages/login.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
void main() => runApp(MaterialApp(
|
||||
void main() => runApp(const Slothmu());
|
||||
|
||||
class Slothmu extends StatefulWidget {
|
||||
const Slothmu({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<Slothmu> createState() => _SlothmuState();
|
||||
}
|
||||
|
||||
class _SlothmuState extends State<Slothmu> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
LocalJsonLocalization.delegate.directories = ['lib/i18n'];
|
||||
return MaterialApp(
|
||||
supportedLocales: const [
|
||||
Locale("en", "US"),
|
||||
Locale("de", "DE"),
|
||||
],
|
||||
locale: const Locale("de", "DE"),
|
||||
localizationsDelegates: [
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
LocalJsonLocalization.delegate,
|
||||
],
|
||||
initialRoute: '/login',
|
||||
|
@ -15,4 +34,6 @@ void main() => runApp(MaterialApp(
|
|||
'/': (context) => const MainScaffold(),
|
||||
'/login': (context) => const Login(),
|
||||
},
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,11 @@ class _LoginFormState extends State<LoginForm> {
|
|||
),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
formKey.currentState!.validate();
|
||||
bool isValid = formKey.currentState!.validate();
|
||||
if (!isValid) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text("login-failed-snackbar-text".i18n())));
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.login),
|
||||
label: Text("authorize-in-browser".i18n()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue