Translations

Also known as contents, translations is a convenient way how to make applications multi-lingual. Upon opening an application, the full contents object is loaded and used for all textual content visible to the customer.

Available variables

The following variables are available in all content strings (starting from FW v5.13.0):

  • input - all collected (and defaulted, prefilled) customer input

  • flags - custom booleans set by the framework

  • quote - all data returned by the quote request

  • asset.{ref} - all the asset URLs available on the item level

  • document.{request}.{ref}.{"url"|"name"} - all the dynamic documents generated by request

  • route - name of the currently active screen

  • dataset.{field_name} - item data from data service

  • query_string - all data from query string

Interface of dataset

{
  [field_name: string]: {
    id: string;
    dataset_id: string;
    [key: string]: any; // Data values from dataset
  };
}

Usage example

"My name is { input.first_name }"
"Selected car model is: { dataset.car.model }"
"Offer document: [{ document.lead.offer.name }]({ document.lead.offer.url })"
"The price is: { quote.gross_premium, asCurrency }"

Available transformers

Not always data is collected from the customers in exactly the same way as displayed back to the customer. For example, when monetary values are collected, they are converted to values in cents (1 Eur = 100). When displaying this value back to the customer, the value needs to be converted back to the original (100 = 1 Eur). This and more is achieved with transformers.

asCurrency

When monetary values are collected they are stored as value in cents (1 Eur = 100). In order to display these values in a human-readable way, the asCurrency filter needs to be used. By default the global price format is used.

"Content string: {quote.gross_premium, asCurrency}"
// -> "Content string: EUR 1 234,56"

The price format can also be overwritten locally by providing it as arguments:

"{quote.gross_premium, asCurrency} | {quote.gross_premium, asCurrency, (amount, 1.2-2, '.', '`')(currencySymbol)}"
// -> "EUR 1 234,56 | 1`234.56€"

For a more detailed explanation see the price format guide.

date

Sometimes the date value collected from the customer needs to be transformed before displaying via content strings. This can be achieved with date transformer.

By default is uses the globally defined date format (or if it's not set, then the default one in the KASKO framework).

"Content string: {input.dob, date}"
// -> "Content string: 27/12/1994"

Custom format can also be configured by passing in an additional argument.

"Content string: {input.dob, date, YYYY-MM-DD}"
// -> "Content string: 1994-12-27"

For full information about the available formats, see the date format guide.

prop

IMPORTANT: Usage of prop transformer is deprecated.

If the value that needs to be retrieved is nested deeply in an object, then props transformer can be used. It cherry-picks the selected key within the object chain.

- "{ input, prop, dob }"
+ "{ input.dob }"

time

IMPORTANT: Usage of time transformer is deprecated. Please use date.

- "{input.dob, time, HH:mm:ss}"
+ "{input.dob, date, HH:mm:ss}"

monetary

IMPORTANT: Usage of monetary transformer is deprecated. Please use asCurrency.

input.item_value = 200010

- "{input.item_value, monetary}"
+ "{input.item_value, asCurrency, (amount, 1.2-2, '.', ',')}"
// -> "2,000.10"

- "{input.item_value, monetary, 1.3-3}"
+ "{input.item_value, asCurrency, (amount, 1.3-3, '.', ',')}"
// -> "2,000.100"

thousands

IMPORTANT: Usage of thousands transformer is deprecated. Please use asCurrency.

input.item_value = 200010

- "{input.item_value, thousands, _}"
+ "{input.item_value, asCurrency, (amount, 1.2-2, '.', '_')}"
// -> "2_000.10"

- "{input.item_value, thousands, _|1}"
+ "{input.item_value, asCurrency, (amount, 1.1-1, '.', '_')}"
// -> "2_000.1"

Last updated