Add script to check language lists stay in sync

This is also run on commits, so we get alerted when we forget to add new locales
This commit is contained in:
Roland Geider
2026-05-18 10:27:25 +02:00
parent 475442e779
commit dcebb3a2e7
6 changed files with 303 additions and 45 deletions

View File

@@ -0,0 +1,57 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (c) 2026 - 2026 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// Native display names for each supported locale, keyed by the locale name
const Map<String, String> languageNativeNames = {
'am': 'አማርኛ',
'ar': 'العربية',
'ca': 'Català',
'cs': 'Čeština',
'de': 'Deutsch',
'el': 'Ελληνικά',
'en': 'English',
'es': 'Español',
'fa': 'فارسی',
'fil': 'Filipino',
'fr': 'Français',
'he': 'עברית',
'hi': 'हिन्दी',
'hr': 'Hrvatski',
'hu': 'Magyar',
'id': 'Bahasa Indonesia',
'it': 'Italiano',
'ja': '日本語',
'ko': '한국어',
'mk': 'Македонски',
'nb': 'Norsk bokmål',
'nl': 'Nederlands',
'pl': 'Polski',
'pt': 'Português',
'pt_BR': 'Português (Brasil)',
'pt_PT': 'Português (Portugal)',
'ro': 'Română',
'ru': 'Русский',
'sk': 'Slovenčina',
'ta': 'தமிழ்',
'th': 'ไทย',
'tr': 'Türkçe',
'uk': 'Українська',
'ur': 'اردو',
'zh': '中文',
'zh_Hant': '繁體中文',
};

View File

@@ -1,6 +1,6 @@
/*
* This file is part of wger Workout Manager <https://github.com/wger-project>.
* Copyright (c) 2026 wger Team
* Copyright (c) 2026 - 2026 wger Team
*
* wger Workout Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -20,52 +20,12 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:wger/helpers/locale.dart';
import 'package:wger/l10n/generated/app_localizations.dart';
import 'package:wger/l10n/language_native_names.dart';
import 'package:wger/providers/user.dart';
/// Native language names for each supported locale. Keys are produced by
/// [encodeLocale] (e.g. `pl`, `pt_BR`, `zh_Hant`).
const Map<String, String> _languageNativeNames = {
'am': 'አማርኛ',
'ar': 'العربية',
'ca': 'Català',
'cs': 'Čeština',
'de': 'Deutsch',
'el': 'Ελληνικά',
'en': 'English',
'es': 'Español',
'fa': 'فارسی',
'fil': 'Filipino',
'fr': 'Français',
'he': 'עברית',
'hi': 'हिन्दी',
'hr': 'Hrvatski',
'hu': 'Magyar',
'id': 'Bahasa Indonesia',
'it': 'Italiano',
'ja': '日本語',
'ko': '한국어',
'mk': 'Македонски',
'nb': 'Norsk bokmål',
'nl': 'Nederlands',
'pl': 'Polski',
'pt': 'Português',
'pt_BR': 'Português (Brasil)',
'pt_PT': 'Português (Portugal)',
'ro': 'Română',
'ru': 'Русский',
'sk': 'Slovenčina',
'ta': 'தமிழ்',
'th': 'ไทย',
'tr': 'Türkçe',
'uk': 'Українська',
'ur': 'اردو',
'zh': '中文',
'zh_Hant': '繁體中文',
};
String _displayNameFor(Locale locale) {
return _languageNativeNames[encodeLocale(locale)] ??
_languageNativeNames[locale.languageCode] ??
return languageNativeNames[encodeLocale(locale)] ??
languageNativeNames[locale.languageCode] ??
encodeLocale(locale);
}