L20n by example

3. Interpolation and External Arguments

In L20n strings may use special syntax to incorporate small pieces of programmable interface. Those pieces are denoted with curly braces { and } and are called placeables.

The most common use case for a placeable is to put an external argument, provided by the developer, into the string.

There are all kinds of external data that might be useful in providing a good localization: user names, number of unread messages, battery level, current time, time left before an alarm goes off, etc.

To reference a context data variable, use the dollar syntax in your L20n code: $user. user has to be defined in the context data. In the examples below, we insert the value of a context data variable into an entity's value.

{ "user": "Jane", "emailCount": 5 }
welcome = Welcome { $user } unreadEmails = { $user } has { $emailCount } unread emails.