From 77a7fa032a5f9089a8097103bff2ad7e45f96e35 Mon Sep 17 00:00:00 2001 From: Nils Jacobsen <58360188+NilsJacobsen@users.noreply.github.com> Date: Tue, 23 May 2023 09:46:39 +0200 Subject: [PATCH 1/3] Update translation.md --- .../software-contributions/translation.md | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/essential-documentation/contribute-to-appflowy/software-contributions/translation.md b/essential-documentation/contribute-to-appflowy/software-contributions/translation.md index e4c008b1..f81653fa 100644 --- a/essential-documentation/contribute-to-appflowy/software-contributions/translation.md +++ b/essential-documentation/contribute-to-appflowy/software-contributions/translation.md @@ -23,15 +23,30 @@ Translation files are located in : `frontend/app_flowy/assets/translations/` ## Steps to add new language -> Adding new languages from within the inlang editor is not supported yet, but you can add the language and then do the translations in inlang. (Adding via inlang is coming soon) +### 1. Add the language resource + +The language resource is a `json` file that needs to be added per language. You can do that via the inlang editor or in code. + +**->Via inlang editor.** + +1. Open the [inlang-editor](https://inlang.com/editor/github.com/AppFlowy-IO/AppFlowy) +2. Press `add language` +3. Enter `language code` +4. (You can start translating) + +**->Via code** + +Add language key-value json file to `frontend/app_flowy/assets/translations/`. Refer `en.json` for format and keys. **NOTE: Translation files SHOULD be** `json` **files named in the format** `-.json` **or just** `.json`**. eg:**`en.json`**,** `en-UK.json` -1. Add language key-value json file to `frontend/app_flowy/assets/translations/`. Refer `en.json` for format and keys. -2. Run `flutter pub run easy_localization:generate -S assets/translations/` -3. Run `flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations` -4. Open the `frontend/app_flowy/lib/startup/tasks/app_widget.dart` file. -5. In the `InitAppWidgetTask` class, add the locale of the language you just created (eg: `Locale('en', 'IN')`, `Locale('en')`) to the `supportedLocales` List : + +### 2. Add the language to the i18n sdk + +1. Run `flutter pub run easy_localization:generate -S assets/translations/` +2. Run `flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations` +3. Open the `frontend/app_flowy/lib/startup/tasks/app_widget.dart` file. +4. In the `InitAppWidgetTask` class, add the locale of the language you just created (eg: `Locale('en', 'IN')`, `Locale('en')`) to the `supportedLocales` List : ```dart runApp( @@ -42,7 +57,7 @@ Translation files are located in : `frontend/app_flowy/assets/translations/` child: app), ); ``` -6. Add the name of your language, in your native tongue, to the list of language names in `AppFlowy/frontend/app_flowy/packages/flowy_infra/lib/language.dart` +5. Add the name of your language, in your native tongue, to the list of language names in `AppFlowy/frontend/app_flowy/packages/flowy_infra/lib/language.dart` ```dart String languageFromLocale(Locale locale) { switch (locale.languageCode) { From 5107ecce606a63f3c74353917297529ee7a912e8 Mon Sep 17 00:00:00 2001 From: Nils Jacobsen <58360188+NilsJacobsen@users.noreply.github.com> Date: Tue, 23 May 2023 09:54:16 +0200 Subject: [PATCH 2/3] Update translation.md --- .../software-contributions/translation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/essential-documentation/contribute-to-appflowy/software-contributions/translation.md b/essential-documentation/contribute-to-appflowy/software-contributions/translation.md index f81653fa..d1606df4 100644 --- a/essential-documentation/contribute-to-appflowy/software-contributions/translation.md +++ b/essential-documentation/contribute-to-appflowy/software-contributions/translation.md @@ -2,6 +2,8 @@ You can help Appflowy in supporting various languages by contributing. Follow the steps below sequentially to contribute translations. +[![translation badge](https://inlang.com/badge?url=github.com/AppFlowy-IO/AppFlowy)](https://inlang.com/editor/AppFlowy-IO/AppFlowy/repo?ref=badge) + ## Steps to modify an existing translation Translation files are located in : `frontend/app_flowy/assets/translations/` From 820b6e053c541ed00e5e035f5600f3220b8e2ca9 Mon Sep 17 00:00:00 2001 From: Nils Jacobsen <58360188+NilsJacobsen@users.noreply.github.com> Date: Wed, 21 Jun 2023 13:29:33 +0200 Subject: [PATCH 3/3] Update wrong link --- .../software-contributions/translation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essential-documentation/contribute-to-appflowy/software-contributions/translation.md b/essential-documentation/contribute-to-appflowy/software-contributions/translation.md index d1606df4..391d9a52 100644 --- a/essential-documentation/contribute-to-appflowy/software-contributions/translation.md +++ b/essential-documentation/contribute-to-appflowy/software-contributions/translation.md @@ -2,7 +2,7 @@ You can help Appflowy in supporting various languages by contributing. Follow the steps below sequentially to contribute translations. -[![translation badge](https://inlang.com/badge?url=github.com/AppFlowy-IO/AppFlowy)](https://inlang.com/editor/AppFlowy-IO/AppFlowy/repo?ref=badge) +[![translation badge](https://inlang.com/badge?url=github.com/AppFlowy-IO/AppFlowy)](https://inlang.com/editor/github.com/AppFlowy-IO/AppFlowy?ref=badge) ## Steps to modify an existing translation