When in Rome...dates appear in Italian! To support global documents and international formatting of dates and numbers, Athennian coders are able to use the following localization functions to translate and format such variables into the right language conventions. For both of these functions, we will be using the ISO time codes, a comprehensive list of which may be found here.
The major advantage of using these localized functions is that the localized language may be specified in one of two ways:
- by conforming to the language setting as defined for the specific template, or
- by forcing a specific language by using the appropriate UTC locale code enclosed in ‘single quotes’.
International Date Formatting with localeTime
The localeTime
function is able to match different localized conventions of date formatting, including translating date elements into the specified language.
International Number Formatting with localeNumber
The localeNumber
function will translate number type data into jurisdiction-specific language requirements. For example, in French, thousandths and millionths places are separated with a space rather than using commaSeparate
as English does (eg. 1 000 vs 1,000), while decimal places are denoted with a comma rather than periods as English does (eg. 1,25 vs 1.25).
Syntax
Using the Template's Language Settings
Using the code templateConfig.language
, you can translate the formatting to the language specified in the template manager settings for the document. For example, this document has French set as the language.
Note: When using the localization functions with templateConfig.language
, it is necessary to use the tilde (~) in order for the qualifier to refer accurately to the template setting language.
localeTime Syntax with ~templateConfig.language
{dateVariable | localeTime:'dateElements': ~templateConfig.language}
Input | Output |
{todaysDate | localeTime:'do MMMM yyyy': ~templateConfig.language} | 5ème janvier 2023 |
localeNumber Syntax with ~templateConfig.language
{numberVariable | localeNumber: ~templateConfig.language}
Number data | Input | Output |
1000 | {numShares | localeNumber: ~templateConfig.language} | 1 000 |
Using the UTC Locale Code
You can also use the appropriate ISO language code to force the language to a certain locale. To specify a language’s standard number format, qualify the localeNumber
function with the 4-letter ISO language code in 'single quotes.'
localeTime Syntax with Locale Code
{dateVariable | localeTime:'dateElements':'languageCode'}
Input | Output |
{todaysDate | localeTime:'do MMMM yyyy':'fr-CA'} | 5ème janvier 2023 |
localeNumber Syntax with Locale Code
{numberVariable | localeNumber:'languageCode'}
Number data | Language | ISO Code | Input | Output |
1000 | Canadian French | fr-CA | {numShares | localeNumber:'fr-CA'} | 1 000 |
Date Elements
Please note the following differences between localized date elements and English date element codes (ie. the difference between using localeTime
vs time
functions):
Localized Date Elements "localeTime" |
Appearance (eg. French) |
Description | Appearance |
English Date Elements "time" |
M | 1 | month in 1 digit | 1 | M |
MM | 01 | month in 2 digits | 01 | MM |
MMM | janv. | month abbreviated | Jan | MMM |
MMMM | janvier | month spelled out fully | January | MMMM |
yyyy | 2023 | year in 4 digits | 2023 | YYYY |
d | 5 | day in 1 digit | 5 | D |
dd | 05 | day in 2 digits | 05 | DD |
do | 5ème | ordinal day | 5th | Do |
EEEE | mardi | day of the week | Tuesday | dddd |
PP | 5 janv. 2023 | formatted abbreviated date | (n/a) | |
PPP | 5ème janvier 2023 | formatted ordinal date | (n/a) |