×

Please give details of the problem

Skip to content

How to format numbers and currencies

Code:

<#assign tmp = 1000000.1246>

<#setting locale = "fr_FR">
French people write integers like: ${tmp?string("#,###")}
French people write decimals like: ${tmp?string("#,##0.00")}

<#setting locale = "en_US">
US people write integers like: ${tmp?string("#,###")}
US people write decimals like: ${tmp?string("#,##0.00")}

<#setting locale = "es_ES">
Spanish people write integers like: ${tmp?string("#,###")}
Spanish people write decimals like: ${tmp?string("#,##0.00")}

<#setting number_format = "currency">
<#setting locale = "fr_FR">
French people write currencies like: ${tmp}

<#setting locale="en_US">
US people write currencies like: ${tmp}

<#setting locale="es_ES">
Spanish people write currencies like: ${tmp}

Result:

French people write integers like: 1 000 000
French people write decimals like: 1 000 000,12

US people write integers like: 1,000,000
US people write decimals like: 1,000,000.12

Spanish people write integers like: 1.000.000
Spanish people write decimals like: 1.000.000,12

French people write currencies like: 1 000 000,12 €
US people write currencies like: $1,000,000.12
Spanish people write currencies like: 1.000.000,12 €

See also How to format numbers and currencies in Javascript