mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-26 11:14:11 +01:00
fix: brazillian localle bug that makes app unresponsive
This commit is contained in:
@@ -1,7 +1,20 @@
|
||||
import 'package:cake_wallet/generated/locales.dart';
|
||||
import 'package:devicelocale/devicelocale.dart';
|
||||
import "package:flutter/widgets.dart";
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
// This will turn stored language code into Flutter Locale.
|
||||
// Some of our language codes uses an underscore (like "pt_BR") and this must be split into language
|
||||
// and country subtags, if we pass the whole string as the languageCode, GlobalMaterialLocalizations
|
||||
// would reject it as an invalid ISO 639-1 code and crash the app on locale switch
|
||||
Locale localeFromLanguageCode(String code) {
|
||||
final parts = code.split("_");
|
||||
if (parts.length == 2 && parts[0].isNotEmpty && parts[1].isNotEmpty) {
|
||||
return Locale(parts[0], parts[1]);
|
||||
}
|
||||
return Locale(code);
|
||||
}
|
||||
|
||||
class LanguageService {
|
||||
static const Map<String, String> supportedLocales = {
|
||||
'en': 'English',
|
||||
|
||||
+1
-1
@@ -426,7 +426,7 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||
themeMode: themeMode,
|
||||
localizationsDelegates: localizationDelegates,
|
||||
supportedLocales: S.delegate.supportedLocales,
|
||||
locale: Locale(appStore.settingsStore.languageCode),
|
||||
locale: localeFromLanguageCode(appStore.settingsStore.languageCode),
|
||||
onGenerateRoute: (settings) => Router.createRoute(settings),
|
||||
initialRoute: initialRoute,
|
||||
scrollBehavior: AppScrollBehavior(),
|
||||
|
||||
Reference in New Issue
Block a user