Price format

Price format (also known as currency template) is used to define the way how prices should be displayed. The template can be set globally (in manifest config object) and then it can be overridden in various parts of an application (for example, in translations).

Default currency template: (currency) (amount)

Example webapp manifest

{
  "version": "1.0",
  "schema": {
    "config": {
      "currency_template": "(currency) (amount, 1.2-2, ',', ' ')"
    }
  }
}

There might also be case where currency symbol should be used, in that case, currency in configuration should not be changed, instead "currency" in currency_template should be replaced with "currencySymbol". Angular will automatically transform currency to symbol.

For example to get output like "1 234,56€" config should look like so:

{
  "version": "1.0",
  "schema": {
    "config": {
      "currency_template": "(amount, 1.2-2, ',', ' ')(currencySymbol)"
    }
  }
}

Configuration string in most cases looks like this (currency) (amount, 1.2-2, '.', ' ') where:

  • currency represents currency variable for example "EUR", "USD" etc.

  • currencySymbol represents monetary value as a symbol transformed from currency variable with getCurrencySymbol method. In "EUR" case it would be "€" etc.

  • amount represents monetary value and it's format configuration sequence separated by comma (,). If some of the values use comma (,), space ( ) or quotes ("|'), then those values should be wrapped in differing quotes e.g. ",","'", '"':

    • DigitsInfo decimal representation options, specified by a string in the following format:{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}. e.g.: 1.2-2

    • DecimalSeparator separator symbol for decimal point. e.g.: ","

    • ThousandsSeparator separator symbol thousands. e.g.: "'"

Customize price format on Content (translation) level with asCurrency transformer.

Sometimes there is a requirement to have a different price format in a specific content string. More information how this can be done is found in translations guide.

Last updated