Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLDR Error] Serbian Locale data cannot load #4904

Closed
1 of 4 tasks
allen138 opened this issue Mar 15, 2022 · 1 comment · Fixed by #4905
Closed
1 of 4 tasks

[CLDR Error] Serbian Locale data cannot load #4904

allen138 opened this issue Mar 15, 2022 · 1 comment · Fixed by #4905
Assignees
Labels
bug This issue is a bug in the code High Prio SAP SF TOPIC Core

Comments

@allen138
Copy link

allen138 commented Mar 15, 2022

Bug Description

Hi team,
There is a discrepancy between openUI5 sap.ui.core.LocaleData and the ui5 webcomponent asset-registries.LocaleData when the locale is Serbian "sh". The ui5-wc code has a mapping that converts 'sh' to 'sr' M_ISO639_OLD_TO_NEW LocaleData.js#L16 while sap.ui.core.LocaleData converts 'sh' to 'sr_Latn' sap.ui.core.LocaleData.js#L2079-L2083. This discrepancy will cause a CLDR error on line asset-registries/LocaleData.js#L95. This can happen when you use the date formatter calling fetchCldr. ex:

import DateFormat from "@ui5/webcomponents-localization/dist/DateFormat";
import { fetchCldr } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js";
import getUserLocale from "@ui5/webcomponents-localization/dist/locale/getLocaleData";

export function getDateFormatter(pattern, cal) {
   (async () => {
      await fetchCldr(await getUserLocale());
      return DateFormat.getInstance({
        pattern: pattern,
        calendarType: cal
      });
   })();
};

getLocaleData will internally create a new LocaleData instance via sap.ui.core.LocaleData and through the constructor is will call getData ui5-wc getLocaleData.js#L21 -> [sap.ui.core.LocaleData.js#L28 constructor|https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L28]. Loader extension calls getLocaleData with the wrong locale: [LoaderExtensions.js#L10|https://github.com/SAP/ui5-webcomponents/blob/v1.1.2/packages/localization/src/sap/base/util/LoaderExtensions.js#L10] and it fails to fallback to English because the localeDataMap only has the 'sr' object in its mapping. Please see:
'sr_Latn' locale being passed to getLocaleData:
image
supported locale map:
image
loader map:
image
localeDataMap
image
Stack:
image

Expected Behavior

  1. ui5-wc should accept 'sr_Latn' as a supported locale
  2. no CLDR error should occur when locale is Serbian
  3. Since ui5-wc uses openui5 under the covers, internal logic should align.

Steps to Reproduce

  1. Please reach out to me via our internal slack channel if you need an instance and replication steps.

Priority

  • Low

  • Medium

  • High

  • Very High

  • Organization: SF

  • Business impact: High

@allen138
Copy link
Author

allen138 commented Mar 15, 2022

Note, This issue occurs with the upgrade to the stable version 1.2.x (uses openUI5 1.94.0), prior I was using 0.31.27 which used openui5 version 1.76.0 and in that version the Serbian logic was the same.
https://github.com/SAP/ui5-webcomponents/blob/v0.31.27/packages/localization/package.json#L26
https://github.com/SAP/openui5/blob/1.76.0/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L3186

@ilhan007 ilhan007 self-assigned this Mar 16, 2022
@ilhan007 ilhan007 added bug This issue is a bug in the code TOPIC Core labels Mar 16, 2022
ilhan007 added a commit that referenced this issue Mar 16, 2022
Support for Serbian Latin has been added in UI5, now we add support for the same in UI5 Web Components.
For Serbian, there are Cyrillic and Latin scripts - "sr" maps to Cyrillic (supported prior to the change), while "sh" and "sr_latn" map to "Latin" (now supported with the current change).

FIXES: #4904
ilhan007 added a commit that referenced this issue Mar 22, 2022
Support for Serbian Latin has been added in UI5, now we add support for the same in UI5 Web Components.
For Serbian, there are Cyrillic and Latin scripts - "sr" maps to Cyrillic (supported prior to the change), while "sh" and "sr_latn" map to "Latin" (now supported with the current change).

FIXES: #4904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug in the code High Prio SAP SF TOPIC Core
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

2 participants