Part 2. Flutter Multilingual Support - Tool Making
Table of Contents
I have created tools that can efficiently complete Flutter multilingual support.
π νκ΅μ΄ λ²μ
Part 1. Flutter Multilingual Support - Ready
βοΈ Part 2. Flutter Multilingual Support - Tool Making
The following tools were created to solve the problems encountered when supporting multilingual languages introduced in Part 1.
- Text Balancer : Balanced text wrapping Flutter Package.
- Flutter Translator : Flutter multi-language support VSCode Extension.
- Figma Translator : Create and translate store templates Figma Plugin.
Text Balancer
Text Balancer is a Flutter package that automatically supports balanced line breaks.
The Text Balancer package eliminates the need to use the line break symbol, so you can solve the text line break problem.
It supports variable width fonts, allows you to specify the number of lines you want, and is implemented to Word Break based on words.
Flutter Translator
Flutter Translator is a VSCode extension with the ability to translate and inspect ARB, Metadata, Changelog, and Xcode Strings files on Flutter projects.
The Flutter Translator extension makes it easy to support multiple languages ββwhile maintaining developer productivity.
ARB Translation
You can translate the source ARB file into another language by running the ARB - Translate
command.
Because it is implemented in batches, translation can continue even if it is interrupted.
Caching functionality is implemented to avoid re-invoking the same request.
Tracks changes to source ARB files so that only changed items are translated.
ARB Translation Exclusion
Basically, parameter names enclosed in curly braces in the ARB file are implemented as translation exclusion. Otherwise, you can add exclusion text by executing the Translation - Exclude
command.
In the v3 version of Google Translate, you can handle translation exceptions by creating a stopwords, but since the v2 translation API was used, items requiring translation exclusion were encoded as emoticons or pronouns, then translated and decoded.
Since the text that survives encoding is different for each language, I translated it in several ways, then quantified the results and selected the translation with the highest score. (The number of parameters, number of parentheses, number of line breaks, and number of translation exclusion keywords were used to quantify the translation results.)
ARB Update & Delete
You may want to change the key of the ARB file. You can easily change the keys using the ARB - Change Keys
command. You can also delete unused keys using the ARB - Delete Keys
command.
ARB Translation Check
You can quickly check the following items using the ARB - Check
command.
- Whether the number of parentheses matches
- Whether the number of parameters matches
- Whether the number of line breaks matches
- Whether the parameter names matches
- Whether the untranslated item exists
- Whether the translation exclusion is applied
- Whether the HTML entities are decoded :
<
Likewise, it checks for the presence of undecoded HTML entities.
When you select a detected item, the source ARB file is displayed on the left and the target ARB file is displayed on the right. Some problems can be solved by turning off the cache and retranslating, but in some cases, manual work is required, so Iβve implemented a feature that takes you to the Google Translate website.
Xcode Strings Translation
Using the Xcode Strings - Translate
command, you can translate the InfoPlist.strings
file containing the iOS permission request text into your desired language.
Metadata creation
You can use the Metadata - Create
command to create Metadata folders for languages ββsupported by each platform. LTR and RTL languages ββare marked so you can easily select the language of the desired category.
The created folder is in a format supported by fastlaneβs upload_to_play_store and deliver is created.
1 | βββ android |
Metadata Translation
You can translate metadata into another language by running the Metadata - Translate
command.
Metadata Check
You can check whether the maximum number of characters for each metadata is exceeded using the Metadata - Check
command.
Play Store | App Store | |
---|---|---|
Metadata | title (30 letters) short_description (80 letters) full_description (4,000 letters) |
name (30 letters) subtitle (30 letters) keywords (100 letters) description (4,000 letters) promotional_text (170 letters) |
Changelog Translation
When distributing your app, you can make changes to the Store in any supported language. For fastlaneβs upload_to_play_store and deliver, you can write a changelog in the following format.
1 | βββ android |
When you run the Changelog - Create
command, Android creates a <buildNumber>.txt
file with the build number specified in the version
of the pubspec.yaml
file, and iOS creates a release_notes.txt
file.
Changelog Translation
You can translate the Changelog into another language by running the Changelog - Translate
command.
Figma Translator
Figma Translator is a Figma Plugin that creates and translates store templates.
With the Figma Translator Plugin, you can quickly create screenshots for your store in multiple languages.
Create Store Templates
You can create store templates for your desired platform by running the Create Templates
command. You can specify the desired device, language, and template scale, and since the UI varies greatly depending on the text direction of the language, I have implemented creation of templates for each text direction.
Templates are created in the form of instances corresponding to the number of components and selected languages, so when you put a design into a component, it is reflected in the instances for each language.
The generated frame name is created as a path for each platform used when distributing Fastlane.
1 | Android/ko-KR/images/featureGraphic |
After extracting the entire screenshot, you can easily add it to your Flutter project using the rsync command.
- Android :
rsync -a <PATH>/Android/ ./android/fastlane/metadata/android/
- iOS :
rsync -a <PATH>/iOS/ ./ios/fastlane/screenshots/
Translate Templates
If you select a frame and run the Translate
command, translation will be performed in the language specified in the frame name. Items that require translation exclusion can be managed by adding them to the Exclude Keywords setting, and once translated content is cached locally.
Even if a single text uses multiple text styles, it will be translated while maintaining the existing styles.
If the text becomes long during translation, there may be issues with line breaks or deviating from the layout. Using the Auto Size option, you can reduce the font size while maintaining the number of lines. However, it will work only if the text constraints are set to Auto Height
.
Finish
It was difficult to meet various problems while supporting the Flutter app in multiple languages, but I was able to experience the VSCode extension and Figma Plugin development that I wanted to make for a long time, so I was able to proceed with it happily.
All of the tools are open source, so ask for your interest and use. π
- Text Balancer : Balanced text wrapping Flutter Package.
- Flutter Translator : Flutter multi-language support VSCode Extension.
- Figma Translator : Create and translate store templates Figma Plugin.
If I get a chance in the future, I will try RTL language too :)
Part 1. Flutter Multilingual Support - Ready
βοΈ Part 2. Flutter Multilingual Support - Tool Making