openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Select dialog search placeholder is not translated according to set locale.

Open GKSoftwareDevelopment opened this issue 5 years ago • 4 comments

OpenUI5 version: All

Browser/version (+device/version): All Any other tested browsers/devices(OK/FAIL): None working URL (minimal example if possible):

https://sapui5.hana.ondemand.com/sdk/#/entity/sap.m.SelectDialog/sample/sap.m.sample.SelectDialog

Steps to reproduce the problem: 0. Have browser in non english locale

  1. Open your own component sample for SelectDialog
  2. Press show select dialog
  3. Observe fields

What is the expected result? Placeholder translated according to sap locale. What happens instead? Locale of browser used.

Snímek obrazovky 2021-06-15 v 10 36 14

GKSoftwareDevelopment avatar Jun 15 '21 08:06 GKSoftwareDevelopment

Hi @GKSoftwareDevelopment The sample serves to showcase how to use the particular control, not how to translate texts. Details such as Localization for the fake data and or title of the actual dialog are omitted for brevity.

In a real application, these texts would be provided by the application developer, so they would be translated. There's a short guide describing how the translation works in the UI5 Demokit here.

This isn't a real bug, so I will close the issue. Feel free to reopen it or create a new issue if you have more questions or something is unclear.

georgimkv avatar Jun 15 '21 11:06 georgimkv

sap.m.SelectDialog does not provide xml attribute to set translation key for sap.m.SearchField contained within. Search field is instantiated by SelectDialog. And no placeholder property is provided by SelectDialog. Therefore default placeholder is used: this.setProperty("placeholder", oResourceBundle.getText("FACETFILTER_SEARCH"),true); ui5 source-code SearchField line 262. resource bundle used is obtained on line 34: sap.ui.getCore().getLibraryResourceBundle("sap.m"); However the reference to bundle is obtained too soon and is initialized with wrong language (when the script is loaded). We set localization when user is logged into the application. So if we open developer console and obtain reference from it: sap.ui.getCore().getLibraryResourceBundle("sap.m").getText("FACETFILTER_SEARCH") yelds correct translation. This draws to conclusion that the ui5 control, in this case Search Field has bundle initalized too soon. The locale is wrong when the element is actually displayed. So to emphasize, the SearchField when instantiated from code without placeholder has translation set only once.

btw. read from source code 1.71.30

GKSoftwareDevelopment avatar Jun 15 '21 12:06 GKSoftwareDevelopment

@GKSoftwareDevelopment Thank you for elaborating futher and for sharing this finding. I've created an internal incident 2180224875. The status of the issue will be updated here in GitHub.

To reproduce this, change the locale in your OS (can use this Chrome extension) and load the SelectDialog sample. Open the first dialog. The SearchField will have its placeholder translated to the language of the current locale, but the "cancel" button of the select dialog will not be translated.

Forcing a language with the sap-ui-language parameter will cause both the button and the placeholder of the search field to be translated, which is correct. sample + sap-ui-language=de

Regards, Georgi

georgimkv avatar Jun 15 '21 12:06 georgimkv

Hello @GKSoftwareDevelopment ,

The issue is now fixed on the master branch.

Best regards, Petar

dimovpetar avatar Jul 06 '21 07:07 dimovpetar