ARB file format is used by Flutter framework for localization. It is a JSON file format that contains translation keys and localized messages. Basically it is a JSON file with a specific structure that is used by Flutter framework to localize your app. It's very similar to a single-language JSON file format, but with a few differences. ARB format uses key-value pairs to store translations, where the key is a translation key and the value is a localized message. It's usually used with the Intl package in Flutter, thus it doesn't support nested keys, arrays or other complex structures as the Intl package doesn't support them.
File format example
This is the most basic example of an ARB file with a few translation keys, localized messages and descriptions.
{
"@@locale": "en",
"home.interface.signup": "Signup",
"@home.interface.signup": {
"description": "The text on the signup button"
},
"home.interface.email": "Email",
"home.interface.password": "Password",
"@home.interface.password": {
"description": "The text on the password input field"
},
"notifications_zero": "No notifications",
"notifications_one": "You have one notification",
"notifications_other": "You have {count} notifications",
"@notifications_other": {
"description": "The text that shows the number of notifications"
}
}
Every translation key is a key in the JSON object, and the value is the localized message. The key can also have a description, which is a comment that describes the translation key.
The description is a key-value pair with the key starting with @
and the value being the description. Under "@" + translation key object you can add specify more metadata about the translation key.
At the moment, SimpleLocalize doesn't support other metadata than the description in ARB files. The support for other metadata will be added in the future.
Message interpolation
Pluralization and variables formatting are done by your translation library (e.g. Intl)
and the library you use for localization in your Flutter app. You can use a {key}
argument for placing a value into the message.
The key is looked up in the input data, and the string is interpolated with its value.
Formatting
{
"hello": "Hello, {name}!"
}
Your variable: name
.
Pluralization
{
"notifications_zero": "No notifications",
"notifications_one": "You have one notification",
"notifications_other": "You have {count} notifications"
}
Learn more about ICU message syntax or use our ICU syntax playground to test your messages.
Upload translation files
Upload with command-line tool
simplelocalize upload --apiKey <PROJECT_KEY> \
--uploadFormat arb \
--uploadLanguageKey en \
--uploadPath ./app_en.arb
Learn more about uploading translations with CLI.
Import with REST API
curl
--request POST \
--url 'https://api.simplelocalize.io/api/v2/import?uploadFormat=arb&languageKey=en' \
--header 'x-simplelocalize-token: <API_KEY>' \
--form file=@/path/to/your/file.arb
Learn more about importing translations with API.
Download translation files
Download with command-line tool
simplelocalize download --apiKey <PROJECT_KEY> \
--downloadFormat arb \
--downloadPath ./app_{lang}.arb
Export with REST API
curl
--request GET \
--url https://api.simplelocalize.io/api/v3/export?downloadFormat=arb \
--header 'x-simplelocalize-token: <API_KEY>'
Learn more about exporting translations with API.