mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Fix string not translatable
This commit is contained in:
parent
7e523ed30c
commit
872196f9e7
4 changed files with 41 additions and 14 deletions
|
@ -301,6 +301,10 @@
|
|||
"@settingsLanguageTitle": {
|
||||
"description": "Set display language"
|
||||
},
|
||||
"settingsLanguageOptionSystemDefaultLabel": "System default",
|
||||
"@settingsLanguageOptionSystemDefaultLabel": {
|
||||
"description": "Follow the Android system language"
|
||||
},
|
||||
"settingsExifSupportTitle": "EXIF support",
|
||||
"@settingsExifSupportTitle": {
|
||||
"description": "Title of the EXIF support setting"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"cs": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"settingsExifWifiOnlyTitle",
|
||||
"settingsExifWifiOnlyFalseSubtitle",
|
||||
"settingsMemoriesTitle",
|
||||
|
@ -145,6 +146,7 @@
|
|||
],
|
||||
|
||||
"de": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"settingsExifWifiOnlyTitle",
|
||||
"settingsExifWifiOnlyFalseSubtitle",
|
||||
"settingsMemoriesTitle",
|
||||
|
@ -304,6 +306,7 @@
|
|||
],
|
||||
|
||||
"el": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"settingsExifWifiOnlyTitle",
|
||||
"settingsExifWifiOnlyFalseSubtitle",
|
||||
"settingsAccountLabelTitle",
|
||||
|
@ -343,6 +346,7 @@
|
|||
],
|
||||
|
||||
"es": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"rootPickerSkipConfirmationDialogContent2",
|
||||
"categoriesLabel",
|
||||
"searchLandingPeopleListEmptyText",
|
||||
|
@ -364,6 +368,7 @@
|
|||
],
|
||||
|
||||
"fi": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"categoriesLabel",
|
||||
"searchLandingPeopleListEmptyText",
|
||||
"searchLandingCategoryVideosLabel",
|
||||
|
@ -385,6 +390,7 @@
|
|||
|
||||
"fr": [
|
||||
"collectionsTooltip",
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"settingsExifWifiOnlyTitle",
|
||||
"settingsExifWifiOnlyFalseSubtitle",
|
||||
"settingsAccountLabelTitle",
|
||||
|
@ -448,6 +454,7 @@
|
|||
],
|
||||
|
||||
"pl": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"settingsExifWifiOnlyTitle",
|
||||
"settingsExifWifiOnlyFalseSubtitle",
|
||||
"settingsAccountLabelTitle",
|
||||
|
@ -529,6 +536,7 @@
|
|||
],
|
||||
|
||||
"pt": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"settingsExifWifiOnlyTitle",
|
||||
"settingsExifWifiOnlyFalseSubtitle",
|
||||
"settingsAccountLabelTitle",
|
||||
|
@ -589,6 +597,7 @@
|
|||
],
|
||||
|
||||
"ru": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"settingsExifWifiOnlyTitle",
|
||||
"settingsExifWifiOnlyFalseSubtitle",
|
||||
"settingsAccountLabelTitle",
|
||||
|
@ -649,6 +658,7 @@
|
|||
],
|
||||
|
||||
"zh": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"settingsExifWifiOnlyTitle",
|
||||
"settingsExifWifiOnlyFalseSubtitle",
|
||||
"settingsAccountLabelTitle",
|
||||
|
@ -709,6 +719,7 @@
|
|||
],
|
||||
|
||||
"zh_Hant": [
|
||||
"settingsLanguageOptionSystemDefaultLabel",
|
||||
"settingsExifWifiOnlyTitle",
|
||||
"settingsExifWifiOnlyFalseSubtitle",
|
||||
"settingsAccountLabelTitle",
|
||||
|
|
|
@ -1,17 +1,38 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:nc_photos/app_localizations.dart';
|
||||
import 'package:nc_photos/pref.dart';
|
||||
|
||||
class AppLanguage {
|
||||
const AppLanguage(this.langId, this.nativeName, this.isoName, this.locale);
|
||||
const AppLanguage(this.langId, this._nativeName, this.isoName, this.locale);
|
||||
|
||||
String get nativeName {
|
||||
if (langId == _AppLanguageEnum.systemDefault.index) {
|
||||
try {
|
||||
return L10n.global().settingsLanguageOptionSystemDefaultLabel;
|
||||
} catch (_) {
|
||||
return _nativeName;
|
||||
}
|
||||
} else {
|
||||
return _nativeName;
|
||||
}
|
||||
}
|
||||
|
||||
final int langId;
|
||||
final String nativeName;
|
||||
final String _nativeName;
|
||||
final String? isoName;
|
||||
final Locale? locale;
|
||||
}
|
||||
|
||||
String getSelectedLanguageName() => _getSelectedLanguage().nativeName;
|
||||
Locale? getSelectedLocale() => _getSelectedLanguage().locale;
|
||||
AppLanguage getSelectedLanguage() {
|
||||
try {
|
||||
final lang = Pref().getLanguageOr(0);
|
||||
return supportedLanguages[lang]!;
|
||||
} catch (_) {
|
||||
return supportedLanguages[_AppLanguageEnum.systemDefault.index]!;
|
||||
}
|
||||
}
|
||||
|
||||
Locale? getSelectedLocale() => getSelectedLanguage().locale;
|
||||
|
||||
final supportedLanguages = {
|
||||
_AppLanguageEnum.systemDefault.index: AppLanguage(
|
||||
|
@ -68,12 +89,3 @@ enum _AppLanguageEnum {
|
|||
chineseHans,
|
||||
chineseHant,
|
||||
}
|
||||
|
||||
AppLanguage _getSelectedLanguage() {
|
||||
try {
|
||||
final lang = Pref().getLanguageOr(0);
|
||||
return supportedLanguages[lang]!;
|
||||
} catch (_) {
|
||||
return supportedLanguages[_AppLanguageEnum.systemDefault.index]!;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class _SettingsState extends State<Settings> {
|
|||
[
|
||||
ListTile(
|
||||
title: Text(L10n.global().settingsLanguageTitle),
|
||||
subtitle: Text(language_util.getSelectedLanguageName()),
|
||||
subtitle: Text(language_util.getSelectedLanguage().nativeName),
|
||||
onTap: () => _onLanguageTap(context),
|
||||
),
|
||||
SwitchListTile(
|
||||
|
|
Loading…
Reference in a new issue