Skip to content

Commit 4305fe1

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 4effb82 commit 4305fe1

14 files changed

+253
-0
lines changed

assets/l10n/app_en.arb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,22 @@
891891
"@openLinksWithInAppBrowser": {
892892
"description": "Label for toggling setting to open links with in-app browser"
893893
},
894+
"languageEn": "English",
895+
"@languageEn": {
896+
"description": "Label for the English language."
897+
},
898+
"languagePl": "Polish",
899+
"@languagePl": {
900+
"description": "Label for the Polish language."
901+
},
902+
"languageRu": "Russian",
903+
"@languageRu": {
904+
"description": "Label for the Russian language."
905+
},
906+
"languageUk": "Ukrainian",
907+
"@languageUk": {
908+
"description": "Label for the Ukrainian language."
909+
},
894910
"pollWidgetQuestionMissing": "No question.",
895911
"@pollWidgetQuestionMissing": {
896912
"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
@@ -1313,6 +1313,30 @@ abstract class ZulipLocalizations {
13131313
/// **'Open links with in-app browser'**
13141314
String get openLinksWithInAppBrowser;
13151315

1316+
/// Label for the English language.
1317+
///
1318+
/// In en, this message translates to:
1319+
/// **'English'**
1320+
String get languageEn;
1321+
1322+
/// Label for the Polish language.
1323+
///
1324+
/// In en, this message translates to:
1325+
/// **'Polish'**
1326+
String get languagePl;
1327+
1328+
/// Label for the Russian language.
1329+
///
1330+
/// In en, this message translates to:
1331+
/// **'Russian'**
1332+
String get languageRu;
1333+
1334+
/// Label for the Ukrainian language.
1335+
///
1336+
/// In en, this message translates to:
1337+
/// **'Ukrainian'**
1338+
String get languageUk;
1339+
13161340
/// Text to display for a poll when the question is missing
13171341
///
13181342
/// 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
@@ -724,6 +724,18 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
724724
@override
725725
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
726726

727+
@override
728+
String get languageEn => 'English';
729+
730+
@override
731+
String get languagePl => 'Polish';
732+
733+
@override
734+
String get languageRu => 'Russian';
735+
736+
@override
737+
String get languageUk => 'Ukrainian';
738+
727739
@override
728740
String get pollWidgetQuestionMissing => 'No question.';
729741

lib/generated/l10n/zulip_localizations_de.dart

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

727+
@override
728+
String get languageEn => 'English';
729+
730+
@override
731+
String get languagePl => 'Polish';
732+
733+
@override
734+
String get languageRu => 'Russian';
735+
736+
@override
737+
String get languageUk => 'Ukrainian';
738+
727739
@override
728740
String get pollWidgetQuestionMissing => 'No question.';
729741

lib/generated/l10n/zulip_localizations_en.dart

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

727+
@override
728+
String get languageEn => 'English';
729+
730+
@override
731+
String get languagePl => 'Polish';
732+
733+
@override
734+
String get languageRu => 'Russian';
735+
736+
@override
737+
String get languageUk => 'Ukrainian';
738+
727739
@override
728740
String get pollWidgetQuestionMissing => 'No question.';
729741

lib/generated/l10n/zulip_localizations_ja.dart

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

727+
@override
728+
String get languageEn => 'English';
729+
730+
@override
731+
String get languagePl => 'Polish';
732+
733+
@override
734+
String get languageRu => 'Russian';
735+
736+
@override
737+
String get languageUk => 'Ukrainian';
738+
727739
@override
728740
String get pollWidgetQuestionMissing => 'No question.';
729741

lib/generated/l10n/zulip_localizations_nb.dart

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

727+
@override
728+
String get languageEn => 'English';
729+
730+
@override
731+
String get languagePl => 'Polish';
732+
733+
@override
734+
String get languageRu => 'Russian';
735+
736+
@override
737+
String get languageUk => 'Ukrainian';
738+
727739
@override
728740
String get pollWidgetQuestionMissing => 'No question.';
729741

lib/generated/l10n/zulip_localizations_pl.dart

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

736+
@override
737+
String get languageEn => 'English';
738+
739+
@override
740+
String get languagePl => 'Polish';
741+
742+
@override
743+
String get languageRu => 'Russian';
744+
745+
@override
746+
String get languageUk => 'Ukrainian';
747+
736748
@override
737749
String get pollWidgetQuestionMissing => 'Brak pytania.';
738750

lib/generated/l10n/zulip_localizations_ru.dart

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

740+
@override
741+
String get languageEn => 'English';
742+
743+
@override
744+
String get languagePl => 'Polish';
745+
746+
@override
747+
String get languageRu => 'Russian';
748+
749+
@override
750+
String get languageUk => 'Ukrainian';
751+
740752
@override
741753
String get pollWidgetQuestionMissing => 'Нет вопроса.';
742754

0 commit comments

Comments
 (0)