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()))
|
||||
|
|
26
pubspec.lock
26
pubspec.lock
|
@ -43,13 +43,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.16.0"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -76,6 +69,11 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
flutter_localizations:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
|
@ -95,6 +93,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.1"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: intl
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.17.0"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -130,13 +135,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
oauth2:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: oauth2
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -29,6 +29,8 @@ environment:
|
|||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_localizations: # Add this line
|
||||
sdk: flutter
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
|
@ -36,7 +38,6 @@ dependencies:
|
|||
cupertino_icons: ^1.0.2
|
||||
settings_ui: ^2.0.2
|
||||
http: ^0.13.4
|
||||
oauth2: ^2.0.0
|
||||
localization: ^2.1.0
|
||||
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in a new issue