-
Go to
lib/l10n -
Create new file called
intl_<language code>_<country code>.arb, examples areintl_en_US.arbfor "English US" orintl_ru_RU.arbfor "Russian" languages. -
Insert template and paste
<language code>_<country code>value for@@locale:{ "@@locale": "", } -
All strings that should be translated are defined as key-value:
"keyOfSomeString": "Some string"If you openintl_en_US.arb, you'll found:{ "@@locale": "en_US", "baseColors": "Base colors", "@baseColors": { "description": "Title for the app bar on palette_page.dart" }, "shades": "Shades", "@shades": { "description": "Part of title for the app bar on color_shade_page.dart, another part is in the end of localization file for all the colors in form 'ofNameColor'" }, ... // other strings }4.1 The required for translation part (from the example above) are localized values -
"Base colors"and"Shades". ThebaseColorsandshadeshere are keys for usage in app. They should not be translated.4.2 There are also entries, which keys started with
@. They are optional and used to provide some description (usage context or anything else) to entries without@. So@baseColorscontains description for entry with keybaseColorsand so on. It's not necessary to translate them, but you can do it if you wish.4.3 ARB files uses the JSON syntax, so don't forget to separate entries with commas
-
WARNING: you don't need to work with files in
lib/generated/intlbecause they are generated fromintl_*_*.arbfiles! -
Add your language name into supported list:
6.0 Open the
lib/locale.dartand find thesupportedLocaleslist:static const supportedLocales = [ Locale('en', 'US') ];
6.1 Add the comma after last entry and add to this list the
Locale('your language code','your country code'), in case of russian it's aLocale('ru', 'RU'), so finally it looks like:static const supportedLocales = [ Locale('en', 'US'), Locale('ru', 'RU') ];
6.2 Scroll down and find a
_languageNamesmap:static const Map<String,String> _languageNames = { 'en_US':'English (US)' };
It's a map, where each
<language code>_<country code>mapped to it's native language name6.3 Add comma after last entry of this map and add new entry related to your translation, i.e. for russian this entry will look
'ru_RU':'Русский'and finally this map should look likestatic const Map<String,String> _languageNames = { 'en_US':'English (US)', 'ru_RU':'Русский' };
This step is not required, but these language names are displayed in app settings. Without language name added to this place, app will show just
<language code>_<country code>, i.e. justru_RUinstead ofРусский. -
Create a pull request with translations.
-
Repeat translation steps 1-6 from guide above
-
Decide if you want to check if translated content looks good by building app locally or using automatic builds. For local building follow steps 3-9, for using automated builds follow steps 10-19
2.1 WARNING: for automated builds you still need Flutter SDK to generate necessary files from
intl_*_*.arbfiles, but you don't need to prepare build environment itself (installing Android Studio/Visual Studio toolchains, installing required libraries for Linux and etc.) -
Download Flutter SDK from https://flutter.dev/docs/get-started/install
-
Choose device where you would like to test app and setup environment:
4.1 Windows (used Win32, not UWP) - https://flutter.dev/docs/get-started/install/windows#windows-setup.
4.2 Linux - https://flutter.dev/docs/get-started/install/linux#linux-setup
4.3 Android - for building on Windows, for building on Linux
4.4 Web browser - https://flutter.dev/docs/get-started/web. P.S.: in case of Windows - Edge may be used instead of Chrome.
-
Optional - Disable Google Analytics by running
flutter config --no-analytics -
Install project dependencies by running
flutter pub get -
Run next command in repository -
flutter pub run intl_utils:generate. It will generate all necessary files from existingintl_*_*.arbfiles. -
Check if selected device found by running
flutter devices8.1 Android emulators need to be launched to be listed here.
8.2 Example output is:
3 connected devices: Android SDK built for x86 64 (mobile) • emulator-5554 • android-x64 • Android 10 (API 29) (emulator) Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1237] Edge (web) • edge • web-javascript • Microsoft Edge 95.0.1020.408.3 Note the "device id", which is shown after first • symbol. So for shown example output Windows "device id" is
windows, MS Edge's id isedgeand Android Emulator's id isemulator-5554 -
Run project on selected device by running
flutter run -d your-selected-device-id. Flutter will build debug version of project and launch it on specified device. -
If you want to use automated builds then go to your fork of project
-
Open repository settings
-
Go to "Actions" and enable Github Actions for your repository
-
You already have 3 config for automated builds at
.github/workflows- there is config to make debug build for windows, linux and android -
Commit and push your translations to your fork (including the generated files from
lib/generated) - this will trigger automated builds for all provided build configs -
Visit in browser your repo url and find there "Actions" tab
-
You'll see all workflow runs (builds)
-
Wait until build finished - there will appear green checkmark icon on the left if build was successfull
-
Open workflow run's info - in case of successfull build you'll see the "Artifacts" section below
-
Download the artifact (which is zip archive exactly with build output), unzip it and run on device.
19.1 Notice that Artifacts available to users which are logged into their Github accounts. Guest won't be able to download artifacts as well as they won't see the build logs
19.2 All built artifacts are debug versions, so they expected to be larger than release builds


