localization support
This commit is contained in:
parent
40d57fb245
commit
bd3e05b354
11 changed files with 34 additions and 84 deletions
|
@ -1,6 +1,5 @@
|
|||
import 'package:http/http.dart' as http;
|
||||
import 'dart:io';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
import 'package:oauth2/oauth2.dart' as oauth2;
|
||||
|
||||
|
|
8
lib/i18n/en_US.json
Normal file
8
lib/i18n/en_US.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"greeting": "Hello!",
|
||||
"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"
|
||||
}
|
||||
|
|
@ -1,8 +1,15 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
import 'package:slothmu/partials/main_scaffold.dart';
|
||||
import 'pages/login.dart';
|
||||
|
||||
void main() => runApp(MaterialApp(
|
||||
supportedLocales: const [
|
||||
Locale("en", "US"),
|
||||
],
|
||||
localizationsDelegates: [
|
||||
LocalJsonLocalization.delegate,
|
||||
],
|
||||
initialRoute: '/login',
|
||||
routes: {
|
||||
'/': (context) => const MainScaffold(),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:slothmu/api/user.dart';
|
||||
import 'package:localization/localization.dart';
|
||||
|
||||
class Login extends StatefulWidget {
|
||||
const Login({Key? key}) : super(key: key);
|
||||
|
@ -40,18 +41,18 @@ class _LoginFormState extends State<LoginForm> {
|
|||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
const Text("Welcome!", style: TextStyle(fontSize: 64)),
|
||||
Text("greeting".i18n(), style: const TextStyle(fontSize: 64)),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: "user id",
|
||||
hintText: "user@example.com",
|
||||
icon: Icon(Icons.person),
|
||||
decoration: InputDecoration(
|
||||
labelText: "user-id".i18n(),
|
||||
hintText: "user-id-example".i18n(),
|
||||
icon: const Icon(Icons.person),
|
||||
prefixText: "@",
|
||||
),
|
||||
autofocus: true,
|
||||
validator: (value) {
|
||||
if (value!.isEmpty || !isValidUsername(name: value)) {
|
||||
return "Sorry, this user id doesn't look quite right...";
|
||||
return "user-id-not-valid".i18n();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -61,8 +62,8 @@ class _LoginFormState extends State<LoginForm> {
|
|||
onPressed: () {
|
||||
final isValid = formKey.currentState!.validate();
|
||||
},
|
||||
icon: Icon(Icons.login),
|
||||
label: Text("authorize in browser"))
|
||||
icon: const Icon(Icons.login),
|
||||
label: Text("authorize-in-browser".i18n()))
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
@ -6,10 +6,6 @@
|
|||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
|
||||
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_secure_storage_linux
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import flutter_secure_storage_macos
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FlutterSecureStorageMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageMacosPlugin"))
|
||||
}
|
||||
|
|
69
pubspec.lock
69
pubspec.lock
|
@ -76,58 +76,11 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
flutter_secure_storage:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_secure_storage
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.0.2"
|
||||
flutter_secure_storage_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_secure_storage_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
flutter_secure_storage_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_secure_storage_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
flutter_secure_storage_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_secure_storage_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
flutter_secure_storage_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_secure_storage_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
flutter_secure_storage_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_secure_storage_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -142,13 +95,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.1"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.4"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -156,6 +102,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
localization:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: localization
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -191,13 +144,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
settings_ui:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -268,4 +214,3 @@ packages:
|
|||
version: "2.1.2"
|
||||
sdks:
|
||||
dart: ">=2.17.3 <3.0.0"
|
||||
flutter: ">=2.0.0"
|
||||
|
|
|
@ -37,7 +37,7 @@ dependencies:
|
|||
settings_ui: ^2.0.2
|
||||
http: ^0.13.4
|
||||
oauth2: ^2.0.0
|
||||
flutter_secure_storage: ^5.0.2
|
||||
localization: ^2.1.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@ -62,7 +62,8 @@ flutter:
|
|||
uses-material-design: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
assets:
|
||||
- lib/i18n/
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_secure_storage_windows
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
|
Loading…
Reference in a new issue