Reputation: 795
For the SAPUI5 app, I want to display number data, according to settings set by user in SU01 (backend transaction, in SAP Logon).
For example, user can set decimal separators as
22,000.000
(twenty two thousand) → US format22.000,000
(twenty two thousand) → German formatBased on these settings, the UI5 app should know which decimal format has been used, and format the data accordingly.
I am trying to follow the topic Number Format, but the issue here is, I need to manually provide region. Ideally, I want to find it from user settings.
var oLocale = new sap.ui.core.Locale("en-US");
var oFormatOptions = {
showMeasure: true
};
Upvotes: 1
Views: 916
Reputation: 18064
Most of the time, app developers don't have to determine the locale explicitly as UI5 already tries to identify the user locale for the app according to the heuristic mentioned in the topic Identifying the Language Code / Locale (See the section "Current Language Code / Locale").
Given the OData property "Freight": "22000"
(typed Edm.Decimal
), the following
sample shows that users can enter the value in their locale format without the app having to determine the locale manually: https://embed.plnkr.co/b32woxbQmdj5dTRu?show=view/Root.view.xml,preview:?sap-ui-xx-componentPreload=off
If the user has e.g. "English (United States)" moved to the top in the browser setting:
If "German (Germany)" is moved to the top:
Upvotes: 1