Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
refactor(translations): fix settings.locale breaking settings
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Oct 21, 2021
1 parent 4870db8 commit 8df97fe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/core/models/translations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class TranslationLocale {
TranslationLocale(this.code, [this.country]);

factory TranslationLocale.parse(final String locale) {
final RegExpMatch match = RegExp('([^_]+)(_(.*?))?').firstMatch(locale)!;
final RegExpMatch match = RegExp('([^_]+)(_(.*))?').firstMatch(locale)!;
final LanguageCodes lang = LanguageUtils.languageCodeMap[match.group(1)!]!;
final LanguageCountries? country = match.groupCount == 3
final LanguageCountries? country = match.group(3) != null
? LanguageCountryUtils.nameCodeMap[match.group(3)!]
: null;

Expand All @@ -34,7 +34,7 @@ class TranslationLocale {

@override
String toString() =>
<String>[code.name, if (country != null) country!.country].join('_');
<String>[code.name, if (country != null) country!.name].join('_');

@override
bool operator ==(final Object other) =>
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/settings_page/setting_labels/preference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ List<Widget> getPreference(
title: Translator.t.language(),
dialogTitle: Translator.t.chooseLanguage(),
icon: Icons.language,
value: settings.locale ?? Translator.t.locale.code.name,
value: Translator.t.locale.toString(),
labels: <String, String>{
for (final TranslationSentences lang in Translator.translations)
lang.locale.code.name: lang.locale.code.language,
lang.locale.toString():
'${lang.locale.code.language} (${lang.locale.toString()})',
},
onChanged: (final String val) async {
settings.locale = val;
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/app_lifecycle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract class AppLifecycle {
try {
await LocalServer.initialize();
Logger.of('LocalServer')
..info('Finsihed "initialize"')
..info('Finished "initialize"')
..info('Serving at ${LocalServer.baseURL}');
} catch (err, trace) {
Logger.of('LocalServer').error(
Expand All @@ -78,7 +78,7 @@ abstract class AppLifecycle {
if (primaryInstance != null) {
try {
await InstanceManager.sendArguments(primaryInstance, args);
Logger.of('InstanceManager').info('Finsihed "sendArguments"');
Logger.of('InstanceManager').info('Finished "sendArguments"');
} catch (err, trace) {
Logger.of('InstanceManager').error(
'"sendArguments" failed: $err',
Expand Down
1 change: 0 additions & 1 deletion packages/utilx/lib/utilities/countries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ enum LanguageCountries {
}

extension LanguageCountriesUtils on LanguageCountries {
String get name => toString().split('.').last.toUpperCase();
String get country => LanguageCountryUtils.codeNameMap[this]!;
}

Expand Down

0 comments on commit 8df97fe

Please sign in to comment.