L20n by example

4. Builtins

In some rare cases the data provided by the developer will require some additional formatting before it can be placed into the string.

L20n provides a list of built-in functions that can help with common operations on the external arguments.

By default, L20n can guess which formatter to run on each kind of argument - DATE, NUMBER, LIST etc., but you can also call the builtin explicitly.

Explicit calls are useful because they allow you to pass additional formatting options that may help make the formatted string look better in the given language. Examples may be defining month as short or long in DATE formatter (using arguments defined in Intl.DateTimeFormat) or whether to use grouping separator when displaying a large number.

{ "lastChecked": "2016-04-22T08:13:56.354Z", "unreadEmails": 5 }
emails = You have { $unreadEmails } unread emails. emails2 = You have { NUMBER($unreadEmails) } unread emails. last-notice = Last checked: { DATETIME($lastChecked, day: "numeric", month: "long") }.