Add de, fr, and fi as support locales
This commit is contained in:
parent
b841d5ecd7
commit
5cd08622ff
6 changed files with 37 additions and 5 deletions
|
@ -62,5 +62,7 @@
|
|||
<string>Please allow auth to lock itself with FaceID or TouchID</string>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>Please allow auth to pick a file to import data from</string>
|
||||
</dict>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -19,7 +19,8 @@ import "package:flutter/material.dart";
|
|||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
class App extends StatefulWidget {
|
||||
const App({Key key});
|
||||
final Locale locale;
|
||||
const App({Key key, this.locale = const Locale("en")}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<App> createState() => _AppState();
|
||||
|
@ -79,6 +80,7 @@ class _AppState extends State<App> {
|
|||
theme: lightTheme,
|
||||
darkTheme: dartTheme,
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: widget.locale,
|
||||
supportedLocales: appSupportedLocales,
|
||||
localeListResolutionCallback: localResolutionCallBack,
|
||||
localizationsDelegates: const [
|
||||
|
@ -97,6 +99,7 @@ class _AppState extends State<App> {
|
|||
theme: lightThemeData,
|
||||
darkTheme: darkThemeData,
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: widget.locale,
|
||||
supportedLocales: appSupportedLocales,
|
||||
localeListResolutionCallback: localResolutionCallBack,
|
||||
localizationsDelegates: const [
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
import 'dart:ui';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
// list of locales which are enabled for auth app.
|
||||
// Add more language to the list only when at least 90% of the strings are
|
||||
// translated in the corresponding language.
|
||||
const List<Locale> appSupportedLocales = <Locale>[
|
||||
Locale('en'),
|
||||
Locale('de'),
|
||||
Locale('fr'),
|
||||
Locale('fi'),
|
||||
];
|
||||
|
||||
Locale localResolutionCallBack(locales, supportedLocales) {
|
||||
// print call stacktrace to identify caller
|
||||
for (Locale locale in locales) {
|
||||
if (appSupportedLocales.contains(locale)) {
|
||||
return locale;
|
||||
|
@ -16,3 +21,17 @@ Locale localResolutionCallBack(locales, supportedLocales) {
|
|||
// if device language is not supported by the app, use en as default
|
||||
return const Locale('en');
|
||||
}
|
||||
|
||||
Future<Locale> getLocale() async {
|
||||
final String? savedLocale =
|
||||
(await SharedPreferences.getInstance()).getString('locale');
|
||||
if (savedLocale != null) {
|
||||
return Locale(savedLocale);
|
||||
}
|
||||
return const Locale('en');
|
||||
}
|
||||
|
||||
Future<void> setLocale(Locale locale) async {
|
||||
await (await SharedPreferences.getInstance())
|
||||
.setString('locale', locale.languageCode);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:ente_auth/core/constants.dart';
|
|||
import 'package:ente_auth/core/logging/super_logging.dart';
|
||||
import 'package:ente_auth/core/network.dart';
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
import 'package:ente_auth/locale.dart';
|
||||
import 'package:ente_auth/services/authenticator_service.dart';
|
||||
import 'package:ente_auth/services/billing_service.dart';
|
||||
import 'package:ente_auth/services/notification_service.dart';
|
||||
|
@ -31,12 +32,14 @@ Future<void> _runInForeground() async {
|
|||
return await _runWithLogs(() async {
|
||||
_logger.info("Starting app in foreground");
|
||||
await _init(false, via: 'mainMethod');
|
||||
final Locale locale = await getLocale();
|
||||
UpdateService.instance.showUpdateNotification();
|
||||
runApp(
|
||||
AppLock(
|
||||
builder: (args) => const App(),
|
||||
builder: (args) => App(locale: locale),
|
||||
lockScreen: const LockScreen(),
|
||||
enabled: Configuration.instance.shouldShowLockScreen(),
|
||||
locale: locale,
|
||||
lightTheme: lightThemeData,
|
||||
darkTheme: darkThemeData,
|
||||
),
|
||||
|
|
|
@ -36,6 +36,7 @@ class AppLock extends StatefulWidget {
|
|||
final Duration backgroundLockLatency;
|
||||
final ThemeData darkTheme;
|
||||
final ThemeData lightTheme;
|
||||
final Locale locale;
|
||||
|
||||
const AppLock({
|
||||
Key key,
|
||||
|
@ -45,6 +46,7 @@ class AppLock extends StatefulWidget {
|
|||
this.backgroundLockLatency = const Duration(seconds: 0),
|
||||
this.darkTheme,
|
||||
this.lightTheme,
|
||||
this.locale,
|
||||
}) : super(key: key);
|
||||
|
||||
static _AppLockState of(BuildContext context) =>
|
||||
|
@ -110,6 +112,7 @@ class _AppLockState extends State<AppLock> with WidgetsBindingObserver {
|
|||
themeMode: ThemeMode.system,
|
||||
theme: widget.lightTheme,
|
||||
darkTheme: widget.darkTheme,
|
||||
locale: widget.locale,
|
||||
supportedLocales: appSupportedLocales,
|
||||
localeListResolutionCallback: localResolutionCallBack,
|
||||
localizationsDelegates: const [
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import "dart:ui";
|
||||
|
||||
import "package:ente_auth/app/app.dart";
|
||||
import "package:flutter_test/flutter_test.dart";
|
||||
|
||||
void main() {
|
||||
group("App", () {
|
||||
testWidgets("renders CounterPage", (tester) async {
|
||||
await tester.pumpWidget(const App());
|
||||
await tester.pumpWidget(const App(Locale("en")));
|
||||
// expect(find.byType(CounterPage), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue