Skip to content

Commit c130a80

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 The difference here being that the display names come from a live ZulipLocalizations instance, so we can't just hardcode the list with literal strings.
1 parent f8677ac commit c130a80

17 files changed

+289
-0
lines changed

assets/l10n/app_en.arb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,22 @@
943943
"@openLinksWithInAppBrowser": {
944944
"description": "Label for toggling setting to open links with in-app browser"
945945
},
946+
"languageEn": "English",
947+
"@languageEn": {
948+
"description": "Label for the English language."
949+
},
950+
"languagePl": "Polish",
951+
"@languagePl": {
952+
"description": "Label for the Polish language."
953+
},
954+
"languageRu": "Russian",
955+
"@languageRu": {
956+
"description": "Label for the Russian language."
957+
},
958+
"languageUk": "Ukrainian",
959+
"@languageUk": {
960+
"description": "Label for the Ukrainian language."
961+
},
946962
"pollWidgetQuestionMissing": "No question.",
947963
"@pollWidgetQuestionMissing": {
948964
"description": "Text to display for a poll when the question is missing"

docs/translation.md

Lines changed: 22 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+
<div 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,26 @@ 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+
by [the update-translations GitHub workflow](/.github/workflows/update-translations.yml).
88+
However, this won't make them in the in-app settings UI.
89+
90+
On [Weblate](https://hosted.weblate.org/projects/zulip/zulip-flutter/),
91+
we can check the percentage of strings translated in each language.
92+
We use this information to determine if we should start offerring the language
93+
in the in-app settings UI. For reference, on the web app, we offer a language
94+
when it is 5% translated. (Search for `percent_translated` in the server code.)
95+
96+
When a language has a good percentage of strings translated, follow these steps
97+
to add it:
98+
99+
- If the language tag is, for example, 'en-GB', [add a string](#add-string)
100+
named 'languageEnGb'.
101+
- Update [localizations.dart](/lib/model/localizations.dart) to include the new language in
102+
`languages`, following the instructions there.
103+
82104
## Hack to enforce locale (for testing, etc.)
83105

84106
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
@@ -1407,6 +1407,30 @@ abstract class ZulipLocalizations {
14071407
/// **'Open links with in-app browser'**
14081408
String get openLinksWithInAppBrowser;
14091409

1410+
/// Label for the English language.
1411+
///
1412+
/// In en, this message translates to:
1413+
/// **'English'**
1414+
String get languageEn;
1415+
1416+
/// Label for the Polish language.
1417+
///
1418+
/// In en, this message translates to:
1419+
/// **'Polish'**
1420+
String get languagePl;
1421+
1422+
/// Label for the Russian language.
1423+
///
1424+
/// In en, this message translates to:
1425+
/// **'Russian'**
1426+
String get languageRu;
1427+
1428+
/// Label for the Ukrainian language.
1429+
///
1430+
/// In en, this message translates to:
1431+
/// **'Ukrainian'**
1432+
String get languageUk;
1433+
14101434
/// Text to display for a poll when the question is missing
14111435
///
14121436
/// 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
@@ -767,6 +767,18 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
767767
@override
768768
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
769769

770+
@override
771+
String get languageEn => 'English';
772+
773+
@override
774+
String get languagePl => 'Polish';
775+
776+
@override
777+
String get languageRu => 'Russian';
778+
779+
@override
780+
String get languageUk => 'Ukrainian';
781+
770782
@override
771783
String get pollWidgetQuestionMissing => 'No question.';
772784

lib/generated/l10n/zulip_localizations_de.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,18 @@ class ZulipLocalizationsDe extends ZulipLocalizations {
767767
@override
768768
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
769769

770+
@override
771+
String get languageEn => 'English';
772+
773+
@override
774+
String get languagePl => 'Polish';
775+
776+
@override
777+
String get languageRu => 'Russian';
778+
779+
@override
780+
String get languageUk => 'Ukrainian';
781+
770782
@override
771783
String get pollWidgetQuestionMissing => 'No question.';
772784

lib/generated/l10n/zulip_localizations_en.dart

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

770+
@override
771+
String get languageEn => 'English';
772+
773+
@override
774+
String get languagePl => 'Polish';
775+
776+
@override
777+
String get languageRu => 'Russian';
778+
779+
@override
780+
String get languageUk => 'Ukrainian';
781+
770782
@override
771783
String get pollWidgetQuestionMissing => 'No question.';
772784

lib/generated/l10n/zulip_localizations_it.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,18 @@ class ZulipLocalizationsIt extends ZulipLocalizations {
773773
@override
774774
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
775775

776+
@override
777+
String get languageEn => 'English';
778+
779+
@override
780+
String get languagePl => 'Polish';
781+
782+
@override
783+
String get languageRu => 'Russian';
784+
785+
@override
786+
String get languageUk => 'Ukrainian';
787+
776788
@override
777789
String get pollWidgetQuestionMissing => 'No question.';
778790

lib/generated/l10n/zulip_localizations_ja.dart

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

770+
@override
771+
String get languageEn => 'English';
772+
773+
@override
774+
String get languagePl => 'Polish';
775+
776+
@override
777+
String get languageRu => 'Russian';
778+
779+
@override
780+
String get languageUk => 'Ukrainian';
781+
770782
@override
771783
String get pollWidgetQuestionMissing => 'No question.';
772784

lib/generated/l10n/zulip_localizations_nb.dart

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

770+
@override
771+
String get languageEn => 'English';
772+
773+
@override
774+
String get languagePl => 'Polish';
775+
776+
@override
777+
String get languageRu => 'Russian';
778+
779+
@override
780+
String get languageUk => 'Ukrainian';
781+
770782
@override
771783
String get pollWidgetQuestionMissing => 'No question.';
772784

lib/generated/l10n/zulip_localizations_pl.dart

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

780+
@override
781+
String get languageEn => 'English';
782+
783+
@override
784+
String get languagePl => 'Polish';
785+
786+
@override
787+
String get languageRu => 'Russian';
788+
789+
@override
790+
String get languageUk => 'Ukrainian';
791+
780792
@override
781793
String get pollWidgetQuestionMissing => 'Brak pytania.';
782794

0 commit comments

Comments
 (0)