peterlu
8 years agoChampion
number format
Hi, For number 1000, US is using 1,000 and EU is using 1.000 In freemarker, we can do things like ${count?string(",##0")} for US But, I want to format the number based on user's language settin...
- 8 years ago
peterlu - There is no built-in function for that. However, you can create a switch case by checking the user language.
<#assign userlang = rest("/users/id/${user.id}/settings/name/profile.language").value> <#assing count = 1000 /> <#switch userlang> <#case "de"> <#-- code --> <#break> <#case "es"> <#-- code --> <#break> <#case "fr"> <#-- code --> <#break> <#case "ja"> <#-- code --> <#break> <#case "ko"> <#-- code --> <#break> <#case "ch"> <#-- code --> <#break> <#case "it"> <#-- code --> <#break> <#default> <#assign formatedNumber = count?string(",##0") /> </#switch> ${formatedNumber}
- 8 years ago
peterlu you can also use the "setting" directive of FreeMarker (http://freemarker.org/docs/ref_directive_setting.html) to set a specific locale value.
Something like this should work (untested):
<#setting locale = settings.name.get("profile.language","en")>