Skip to content

Commit 44b878f

Browse files
committed
i18n: Maintain a list of supported languages with metadata
This is similar to what we did in zulip-mobile: https://github.com/zulip/zulip-mobile/blob/91f5c3289/src/settings/languages.js
1 parent 9689dce commit 44b878f

13 files changed

+235
-0
lines changed

assets/l10n/app_en.arb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,22 @@
835835
"@openLinksWithInAppBrowser": {
836836
"description": "Label for toggling setting to open links with in-app browser"
837837
},
838+
"languageEn": "English",
839+
"@languageEn": {
840+
"description": "Label for the English language."
841+
},
842+
"languagePl": "Polish",
843+
"@languagePl": {
844+
"description": "Label for the Polish language."
845+
},
846+
"languageRu": "Russian",
847+
"@languageRu": {
848+
"description": "Label for the Russian language."
849+
},
850+
"languageUk": "Ukrainian",
851+
"@languageUk": {
852+
"description": "Label for the Ukrainian language."
853+
},
838854
"pollWidgetQuestionMissing": "No question.",
839855
"@pollWidgetQuestionMissing": {
840856
"description": "Text to display for a poll when the question is missing"

docs/translation.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ is working correctly.
2525

2626
## Adding new UI strings
2727

28+
<a id="add-string" />
29+
2830
### Adding a string to the translation database
2931

3032
To add a new string in the UI, start by
@@ -79,6 +81,21 @@ For example:
7981
`zulipLocalizations.subscribedToNChannels(store.subscriptions.length)`.
8082

8183

84+
## Adding a new language
85+
86+
ARB files for new languages are automatically created in Pull Requests generated
87+
[the update-translations GitHub workflow](/.github/workflows/update-translations.yml).
88+
However, this won't make them appear in settings.
89+
90+
When a language has a good percentage of strings translated, we should add it to
91+
settings. First, if the language tag is 'en-GB', [add a string](#add-string)
92+
named 'languageNameEnGb'.
93+
94+
Then, update [localizations.dart](/lib/model/localizations.dart) to include
95+
the new language in `kSelfnamesByLocale` and `localeDisplayName`, following
96+
the instructions there.
97+
98+
8299
## Hack to enforce locale (for testing, etc.)
83100

84101
For testing the app's behavior in different locales,

lib/generated/l10n/zulip_localizations.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,30 @@ abstract class ZulipLocalizations {
12261226
/// **'Open links with in-app browser'**
12271227
String get openLinksWithInAppBrowser;
12281228

1229+
/// Label for the English language.
1230+
///
1231+
/// In en, this message translates to:
1232+
/// **'English'**
1233+
String get languageEn;
1234+
1235+
/// Label for the Polish language.
1236+
///
1237+
/// In en, this message translates to:
1238+
/// **'Polish'**
1239+
String get languagePl;
1240+
1241+
/// Label for the Russian language.
1242+
///
1243+
/// In en, this message translates to:
1244+
/// **'Russian'**
1245+
String get languageRu;
1246+
1247+
/// Label for the Ukrainian language.
1248+
///
1249+
/// In en, this message translates to:
1250+
/// **'Ukrainian'**
1251+
String get languageUk;
1252+
12291253
/// Text to display for a poll when the question is missing
12301254
///
12311255
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,18 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
679679
@override
680680
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
681681

682+
@override
683+
String get languageEn => 'English';
684+
685+
@override
686+
String get languagePl => 'Polish';
687+
688+
@override
689+
String get languageRu => 'Russian';
690+
691+
@override
692+
String get languageUk => 'Ukrainian';
693+
682694
@override
683695
String get pollWidgetQuestionMissing => 'No question.';
684696

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,18 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
679679
@override
680680
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
681681

682+
@override
683+
String get languageEn => 'English';
684+
685+
@override
686+
String get languagePl => 'Polish';
687+
688+
@override
689+
String get languageRu => 'Russian';
690+
691+
@override
692+
String get languageUk => 'Ukrainian';
693+
682694
@override
683695
String get pollWidgetQuestionMissing => 'No question.';
684696

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,18 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
679679
@override
680680
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
681681

682+
@override
683+
String get languageEn => 'English';
684+
685+
@override
686+
String get languagePl => 'Polish';
687+
688+
@override
689+
String get languageRu => 'Russian';
690+
691+
@override
692+
String get languageUk => 'Ukrainian';
693+
682694
@override
683695
String get pollWidgetQuestionMissing => 'No question.';
684696

lib/generated/l10n/zulip_localizations_nb.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,18 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
679679
@override
680680
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
681681

682+
@override
683+
String get languageEn => 'English';
684+
685+
@override
686+
String get languagePl => 'Polish';
687+
688+
@override
689+
String get languageRu => 'Russian';
690+
691+
@override
692+
String get languageUk => 'Ukrainian';
693+
682694
@override
683695
String get pollWidgetQuestionMissing => 'No question.';
684696

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,18 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
688688
@override
689689
String get openLinksWithInAppBrowser => 'Otwieraj odnośniki w aplikacji';
690690

691+
@override
692+
String get languageEn => 'English';
693+
694+
@override
695+
String get languagePl => 'Polish';
696+
697+
@override
698+
String get languageRu => 'Russian';
699+
700+
@override
701+
String get languageUk => 'Ukrainian';
702+
691703
@override
692704
String get pollWidgetQuestionMissing => 'Brak pytania.';
693705

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,18 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
692692
@override
693693
String get openLinksWithInAppBrowser => 'Открывать ссылки внутри приложения';
694694

695+
@override
696+
String get languageEn => 'English';
697+
698+
@override
699+
String get languagePl => 'Polish';
700+
701+
@override
702+
String get languageRu => 'Russian';
703+
704+
@override
705+
String get languageUk => 'Ukrainian';
706+
695707
@override
696708
String get pollWidgetQuestionMissing => 'Нет вопроса.';
697709

lib/generated/l10n/zulip_localizations_sk.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,18 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
681681
@override
682682
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
683683

684+
@override
685+
String get languageEn => 'English';
686+
687+
@override
688+
String get languagePl => 'Polish';
689+
690+
@override
691+
String get languageRu => 'Russian';
692+
693+
@override
694+
String get languageUk => 'Ukrainian';
695+
684696
@override
685697
String get pollWidgetQuestionMissing => 'Bez otázky.';
686698

0 commit comments

Comments
 (0)