Skip to Content
Author's profile photo Jerry Wang

An example of Fiori Globalization implementation – the logic of amount value truncation

You have observed the following behavior: the sales volume is displayed in detail view with 1880 USD, while in master list, it is displayed as 2K for short. Why?

/wp-content/uploads/2016/04/clipboard1_926853.png

The truncation behavior in master list is implemented by Fiori application to fulfill the product standard of Globalization requirement.

The exact value for SalesVolume is 1880.00,

/wp-content/uploads/2016/04/clipboard2_926854.png

And for the field in master list, there is a formatter to return the volume in short format:

/wp-content/uploads/2016/04/clipboard3_926867.png

/wp-content/uploads/2016/04/clipboard4_926868.png

And in order to understand the implementation detail of framework API “FormatAmountShort”, we have to understand the definition of CLDR – Unicode Common Locale Data Repository.

The Unicode CLDR provides key building blocks for software to support the world’s languages, with the largest and most extensive standard repository of locale data available. This data is used by a wide spectrum of companies for their software internationalization and localization, adapting software to the conventions of different languages for such common software tasks. See one part of CLDR definition below from http://cldr.unicode.org/translation/number-patterns :

/wp-content/uploads/2016/04/clipboard5_926871.png

The first call of FormatAmountShort will trigger the load of CLDR file in the runtime.

/wp-content/uploads/2016/04/clipboard6_926876.png

The English version of CLDR content defined in the web page http://cldr.unicode.org/ is packed and stored in JSON file en.json by SAP and is now loaded:

/wp-content/uploads/2016/04/clipboard7_926877.png

And here below is the code how “1880” is transformed to “2k” by framework code:

/wp-content/uploads/2016/04/clipboard8_926878.png

The reason why English version of CLDR file is loaded is the language setting of the browser.

UI5 runtime will use the first Language configured in browser as primary language for all subsequent language-specific configuration stuff load mechanism, as illustrated in line 67 below:

/wp-content/uploads/2016/04/clipboard9_926879.png

Finally the English version of CLDR file is loaded in line 718:

/wp-content/uploads/2016/04/clipboard10_926880.png

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jocelyn Dart
      Jocelyn Dart

      Fascinating! Another of life's little mysteries solved. Thanks.