[GH-ISSUE #117] [FR] i18n support #59

Closed
opened 2026-03-23 20:31:11 +00:00 by mirror · 4 comments
Owner

Originally created by @0xN0x on GitHub (Dec 3, 2021).
Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/117

Originally assigned to: @irfanbacker on GitHub.

Hi there !

As i was reading the code, i saw that the app is not at all made for i18n support. I can understand it's not the priority but by not working at least with a unique english file you will lose some time in the future to migrate every strings used by the app.

The app is still new but already watched by a lot of people. Planning a multi-language support is mandatory if you want to be a good alternative to Notion.
And with the open-source community, the translations can be very quick.

Every users can benefits from this, but mainly people don't having english as their main language. It can also ultimately facilitate (when the project has grown) the management of strings and therefore finding typos.

Also, there's tools like Weblate that can help you and the community to manage the translations files.

It's going to be something quite a long time to catch up (and the more something is delayed, the longer it will take to catch up). But at least, now there is an issue for that and it can be discussed.

Originally created by @0xN0x on GitHub (Dec 3, 2021). Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/117 Originally assigned to: @irfanbacker on GitHub. Hi there ! As i was reading the code, i saw that the app is not at all made for i18n support. I can understand it's not the priority but by not working at least with a unique english file you will lose some time in the future to migrate every strings used by the app. The app is still new but already watched by a lot of people. Planning a multi-language support is mandatory if you want to be a good alternative to Notion. And with the open-source community, the translations can be very quick. Every users can benefits from this, but mainly people don't having english as their main language. It can also ultimately facilitate (when the project has grown) the management of strings and therefore finding typos. Also, there's tools like Weblate that can help you and the community to manage the translations files. It's going to be something quite a long time to catch up (and the more something is delayed, the longer it will take to catch up). But at least, now there is an issue for that and it can be discussed.
Author
Owner

@irfanbacker commented on GitHub (Dec 6, 2021):

@annieappflowy I'll take this issue up if no ones working on it

<!-- gh-comment-id:987210186 --> @irfanbacker commented on GitHub (Dec 6, 2021): @annieappflowy I'll take this issue up if no ones working on it
Author
Owner

@annieappflowy commented on GitHub (Dec 7, 2021):

@annieappflowy I'll take this issue up if no ones working on it

Awesome. I’ll tag you on this issue posted on Discord #pr-wanted

Please feel free to reach us if you need help.

<!-- gh-comment-id:987559634 --> @annieappflowy commented on GitHub (Dec 7, 2021): > @annieappflowy I'll take this issue up if no ones working on it Awesome. I’ll tag you on this issue posted on Discord #pr-wanted Please feel free to reach us if you need help.
Author
Owner

@irfanbacker commented on GitHub (Dec 7, 2021):

i18n approach

  • Using package easy_localization
  • Translation files will be under assets/translations/ directory
  • Translations files are json files named in the format <lang_code>-<country_code>.json or just <lang_code>.json.
    eg: en.json, en-UK.json
  • A wrapper around MaterialApp will be added to provide localization
    runApp(
      EasyLocalization(
          supportedLocales: const [Locale('en'), Locale('es', 'BR')], // Newly added languages should be added here
          path: 'assets/translations', // Path to translation .json files
          fallbackLocale: const Locale('en'), // Default locale if system locale not in supportedLocales
          child: app), // App startpoint i.e, ApplicationWidget in this case
    );
    
  • Example en-US.json file
    {
        "appName": "Appflowy",
        "defaultUsername": "Me",
        "welcomeText": "Welcome to @:appName",
        "githubStarText": "Star on GitHub",
        "subscribeNewsletterText": "Subscribe to Newsletter",
        "letsGoButtonText": "Let's Go",
    }
    
    Other features such as named arguments, gender and plurals etc. are supported and can be implemented refering to the documentation of easy_localization.
  • i18n usage for appName from example above:
    LocaleKeys.appName.tr() or "appName".tr()
    Imports needed:
    'package:easy_localization/easy_localization.dart' and
    'package:app_flowy/generated/locale_keys.g.dart' (Optional. Needed only if LocaleKeys class is used)

Steps to add new language support

  1. Add language key-value json file to assets/translations/.
  2. Run flutter pub run easy_localization:generate -S assets/translations/ to generate code from the json files.
  3. Run flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations to generate LocaleKeys for proper keys on dart (This is needed to use LocaleKeys.appName.tr()).
  4. Add locale of the language (eg: Locale('en', 'IN')) in supportedLocales list under EasyLocalization wrapper for flutter to support it.

Steps to modify translations

  1. Modify the specific translation file
  2. Run flutter pub run easy_localization:generate -S assets/translations/ to generate code from the json files.
  3. Run flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations to generate LocaleKeys for proper keys on dart (This is needed to use LocaleKeys.appName.tr()).

@appflowy Please review this approach and do let me know if any changes are needed.

<!-- gh-comment-id:987699345 --> @irfanbacker commented on GitHub (Dec 7, 2021): # i18n approach - Using package [easy_localization](https://pub.dev/packages/easy_localization) - Translation files will be under `assets/translations/` directory - Translations files are `json` files named in the format `<lang_code>-<country_code>.json` or just `<lang_code>.json`. eg: `en.json`, `en-UK.json` - A wrapper around `MaterialApp` will be added to provide localization ```dart runApp( EasyLocalization( supportedLocales: const [Locale('en'), Locale('es', 'BR')], // Newly added languages should be added here path: 'assets/translations', // Path to translation .json files fallbackLocale: const Locale('en'), // Default locale if system locale not in supportedLocales child: app), // App startpoint i.e, ApplicationWidget in this case ); ``` - Example `en-US.json` file ```json { "appName": "Appflowy", "defaultUsername": "Me", "welcomeText": "Welcome to @:appName", "githubStarText": "Star on GitHub", "subscribeNewsletterText": "Subscribe to Newsletter", "letsGoButtonText": "Let's Go", } ``` Other features such as named arguments, gender and plurals etc. are supported and can be implemented refering to the documentation of `easy_localization`. - i18n usage for `appName` from example above: `LocaleKeys.appName.tr()` or `"appName".tr()` Imports needed: `'package:easy_localization/easy_localization.dart'` and `'package:app_flowy/generated/locale_keys.g.dart'` (Optional. Needed only if `LocaleKeys` class is used) ## Steps to add new language support 1. Add language key-value json file to `assets/translations/`. 2. Run `flutter pub run easy_localization:generate -S assets/translations/` to generate code from the `json` files. 3. Run `flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations` to generate `LocaleKeys` for proper keys on dart (This is needed to use `LocaleKeys.appName.tr()`). 4. Add locale of the language (eg: `Locale('en', 'IN')`) in `supportedLocales` list under `EasyLocalization` wrapper for flutter to support it. ## Steps to modify translations 1. Modify the specific translation file 2. Run `flutter pub run easy_localization:generate -S assets/translations/` to generate code from the `json` files. 3. Run `flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart -S assets/translations` to generate `LocaleKeys` for proper keys on dart (This is needed to use `LocaleKeys.appName.tr()`). @appflowy Please review this approach and do let me know if any changes are needed.
Author
Owner

@appflowy commented on GitHub (Dec 8, 2021):

@irfanbacker easy_localization is really scalable and extensible. It supports all the platforms that we need. LGTM!

<!-- gh-comment-id:988391224 --> @appflowy commented on GitHub (Dec 8, 2021): @irfanbacker easy_localization is really scalable and extensible. It supports all the platforms that we need. LGTM!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#59
No description provided.