diff --git a/essential-documentation/contribute-to-appflowy/software-contributions/translation.md b/essential-documentation/contribute-to-appflowy/software-contributions/translation.md index e4c008b1..391d9a52 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/github.com/AppFlowy-IO/AppFlowy?ref=badge) + ## Steps to modify an existing translation Translation files are located in : `frontend/app_flowy/assets/translations/` @@ -23,15 +25,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 +59,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) {