Support & Downloads

Quisque actraqum nunc no dolor sit ametaugue dolor. Lorem ipsum dolor sit amet, consyect etur adipiscing elit.

s f

Contact Info
198 West 21th Street, Suite 721
New York, NY 10010
youremail@yourdomain.com
+88 (0) 101 0000 000
Follow Us

Flutter ARB file (.arb)

What is ARB file?

ARB stands for Application Resource Bundle. It is actually a JSON file on steroids intended for localization, with .arb extension. Since it is based on JSON, it just defines standardized ways how to add more information around key-value pairs.

ARB files offer a lot of capabilities, but here we will mention only those relevant for Flutter applications.

Sample ARB file

{
  "@@locale" : "en",

  "appName" : "Demo app",
  
  "pageLoginUsername" : "Your username",
  "@pageLoginUsername" : {},
  
  "pageLoginPassword" : "Your password",
  "@pageLoginPassword" : {},

  "pageHomeTitle" : "Welcome {firstName}",
  "@pageHomeTitle" : {
    "description" : "Welcome message on the Home screen",
    "placeholders": {
        "firstName": {}
    }
  },

  "pageHomeInboxCount" : "{count, plural, zero{You have no new messages} one{You have 1 new message} other{You have {count} new messages}}",
  "@pageHomeInboxCount" : {
    "description" : "New messages count on the Home screen",
    "placeholders": {
        "count": {}
    }
  },

  "pageHomeBirthday": "{sex, select, male{His birthday} female{Her birthday} other{Its birthday}}",
   "@pageHomeBirthday": {
       "description": "Birthday message on the Home screen",
       "placeholders": {
           "sex": {}
       }
   },

   "commonVehicleType": "{vehicleType, select, sedan{Sedan} cabriolet{Solid roof cabriolet} truck{16 wheel truck} other{Other}}",
    "@pageHomeVehicle": {
        "description": "Vehicle type",
        "placeholders": {
            "vehicleType": {}
        }
    }
}

In the given example we have the following:

  • “@@locale” – (optional) a global attribute that defined locale for translated strings
  • “appName” – a minimal key-value pair with translation
  • “@pageLoginUsername” – a key prefixed with @ represents a json object with additional attributes for the same key. It is optional if using Flutter Intl IDE plugin
  • “description”– (optional) short text describing the string key and how it is being used in the app, explaining the context to translators
  • “placeholders” – A map of placeholder ids. It is optional if using Flutter Intl IDE plugin. Otherwise, all placeholders from translation should be listed.

 

ARB file features

All localization file formats have some specific features. Here we will list those for ARB file, relevant for Flutter apps.

Placeholder

Placeholder is marked by curly brackets. Variable name inside {} must be a valid identifier, like {firstName}.

Plural

Plurals are defined with ICU syntax.

"pageHomeInboxCount" : "{count, plural, zero{You have no new messages} one{You have 1 new message} other{You have {count} new messages}}",
"@pageHomeInboxCount" : {
    "description" : "New messages count on the Home screen",
    "placeholders": {
        "count": {}
    }
},

other is a mandatory case.

Gender

Genders are defined with ICU syntax.

"pageHomeBirthday": "{sex, select, male{His birthday} female{Her birthday} other{Its birthday}}",
"@pageHomeBirthday": {
    "description": "Birthday message on the Home screen",
        "placeholders": {
        "sex": {}
    }
},

other is a mandatory case.

Select

Custom selects are defined with ICU syntax.

"commonVehicleType": "{vehicleType, select, sedan{Sedan} cabriolet{Solid roof cabriolet} truck{16 wheel truck} other{Other}}",
"@pageHomeVehicle": {
    "description": "Vehicle type",
    "placeholders": {
        "vehicleType": {}
    }
}

other is a mandatory case.

Newline

Since ARB file is based on JSON structure, a new line needs to be escaped with `\n` character.
Note that actual printing on the screen depends on the widget used.

"pageHomeTitle": "Welcome,\n{firstName}",