Localization: Translating Your Code

Joanna Payoyo
Joanna Payoyo Athennian DocAuto Team Document Coding - Level 3
  • Updated

International Time Formatting with localeTime Function

When coding documents in different languages, we would use localeTime function in order to match different localization conventions of date formatting.

Syntax

{dateVariable | localeTime:'dateFormat':languageCode}

The major difference with using localeTime over time is that the localized language must be specified by either 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’.

templateConfig.language

Using templateConfig.language, you can translate the time format to the language setting in template manager.

Example Code

Result

{todaysDate | localeTime:'do MMMM yyyy': ~templateConfig.language}

30ème septembre 2022

UTC Locale Code

You can also use the 2-letter ISO language code to force the language to a certain locale.

Example Code

Result

{todaysDate | localeTime:'do MMMM yyyy':'fr-CA'}

30ème septembre 2022

For a complete list of ISO language codes, please refer to this external page.

International Number Formatting with localeNumber

This function will translate number type data into jurisdiction-specific language requirements. For example, in Quebec 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

To specify a language’s standard number format, qualify the localeNumber function with the 4-letter ISO language code in 'single quotes.' For example, I would like to format :

Language

ISO Code

Sample Code

Result

French (Canada)

fr-CA

{numShares | localeNumber:'fr-CA'}

1 000

For a comprehensive list of the ISO codes available, please refer to this list of ISO Language Codes.

To specify the language as set in the template settings in Template Manager, simply use ~templateConfig.language in place of the ISO code.

Template Setting

Sample Code

Result

French

{numShares | localeNumber: ~templateConfig.language}

1 000

When using the localeNumber function with templateConfig.language, it is necessary to use the tilde (~) in order for the qualifier to refer accurately to the template setting language.

{#certificates}{numShares | localeNumber: ~templateConfig.language}{/}