From 4a49669cc555f67d0d37129749d0d9614ca8a55d Mon Sep 17 00:00:00 2001 From: Mike <mike@wallacehub.com> Date: Wed, 15 Dec 2021 17:41:02 -0500 Subject: [PATCH] Put the steps for existing translations first, this will be the most used case. Simplified the wording of the 'add new language' case. --- doc/TRANSLATION.md | 48 ++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/doc/TRANSLATION.md b/doc/TRANSLATION.md index a3588b9e77..9809a6ad65 100644 --- a/doc/TRANSLATION.md +++ b/doc/TRANSLATION.md @@ -2,28 +2,30 @@ You can help Appflowy in supporting various languages by contributing. Follow the steps below sequentially to contribute translations. -**NOTE: Translation files SHOULD be** `json` **files named in the format** `<lang_code>-<country_code>.json` **or just** `<lang_code>.json`**. eg:**`en.json`**,** `en-UK.json` - -## Steps to add new language support - -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. Add locale of the language (eg: `Locale('en', 'IN')`, `Locale('en')`) in `supportedLocales` list under `EasyLocalization` wrapper for flutter to support it. -This is located in `frontend/app_flowy/lib/startup/tasks/application_widget.dart` under `AppWidgetTask` class as shown below: - - ```dart - runApp( - EasyLocalization( - supportedLocales: const [ Locale('en') ], // <---- Add locale to this list - path: 'assets/translations', - fallbackLocale: const Locale('en'), - child: app), - ); - ``` - -## Steps to modify translations +## Steps to modify an existing translation +Translation files are located in : `frontend/app_flowy/assets/translations/` 1. Modify the specific translation file. -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`. +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. Verify that the translation has changed appropriately by compiling and running the app. + +## Steps to add new language + +**NOTE: Translation files SHOULD be** `json` **files named in the format** `<lang_code>-<country_code>.json` **or just** `<lang_code>.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/application_widget.dart` file. +5. In the `AppWidgetTask` class, add the locale of the language you just created (eg: `Locale('en', 'IN')`, `Locale('en')`) to the `supportedLocales` List : + + ```dart + runApp( + EasyLocalization( + supportedLocales: const [Locale('en'), Locale('zh_CN')], // <---- Add locale to this list + path: 'assets/translations', + fallbackLocale: const Locale('en'), + child: app), + ); + ```