Formatting numbers and dates

All numbers and dates are formatted inside StoryTeller.

The standard delivered formatting is done with the help of variables which are used in the modification field inside StoryTeller. These variables utilize the locale setting of XML to format numbers correctly, depending on the language and the country. The date format, thousand separator, and decimal format are not used in the standard solution. You can access the value of the locale using the $locale variable.

To format numbers and dates according to locale that uses the modification field, these variables must be set:

  • $localeNumCurrFormat

    This formats the number as a currency for the country of the locale.

  • $localeNumFormatXdec

    This formats the number with X number of decimals, with X is 0->9-.

  • $localeNumFormat

    This variable should always be used in conjunction with the setLocaleNumFormatDecimals(string) function. The function takes the xpath of the current substitution field as an argument, then sets $localeNumFormat to use the correct amount of decimals. This variable is used on numbers without a fixed amount of decimals or values which are not currency amounts.

    Note: Always add the script and the modification when using this variable.
  • $localeDateCurrFormat

    This formats the date in the standard short format for the locale.

If more alternatives are required, then add the variables to the setGlobalFormats in the global function file.

For example: $localeNumMediumDateFormat = "date.medium{} (" + $Locale + "){}"; could be added to use medium date format for given locale.

Another alternative is to use the formats provided in StoryTeller. Only use these formats if specific locale settings are required.