on 09-10-2014 3:26 PM
Hi Everone!
I have a problem with setting a default language for my sapui5 app. I've found the information that in order to set a language during initialization the data-sap-ui-language="en" parameter has to be added (SAP HANA Developer Guide - SAP Library).
The thing is that when I test the app localy (using proxy and Tomcat) it works fine, language is always set to English, but .. when I submit the app's code to SAP repository and run it as the BSP application it doesn't see this parameter (I've checked inside sap-ui-core.js and there is a method which returns a default value for language parameter, which is my web broser language - it uses windows.navigator.language property).
However, when I use the url parameter (sap-language=EN) it works fine, but the value is easy to be changed by end users, so I'd like to set it inside the code.
I would be very grateful for any help you can provide!
Tomasz Sobkowiak
You can set the language to the Core or to the ResourceModel.
Core:
sap.ui.getCore().getConfiguration().setLanguage("pt-BR");
ResourceModel:
var i18nModel = new sap.ui.model.resource.ResourceModel({
bundleUrl : "./i18n/messageBundle.properties",
bundleLocale : "pt-BR"
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mauricio,
thanks for an answer, but it doesn't fix altogether the issue. Now some of the labels are translated, but a few controls are not, i.e. placeholder of sap.m.Search uses the following method:
this.setProperty('placeholder', sap.ui.getCore().getLibraryResourceBundle('sap.m').getText('FACETFILTER_SEARCH'), true)
and the resource bundle has different language then 'en' (it has the language of the web browser).
It seems that sap.ui.getCore().getConfiguration().setLanguage("en") doesn't matter, only bundleLocal : "en" changes something.
Best regards,
Tomasz Sobkowiak
I even tried to set the language in the following way:
<script type="text/javascript">
window["sap-ui-config"] = {
"language" : "en"
}
</script>
<script src="resources/sap-ui-core.js" type="text/javascript"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m,sap.ca.common.uilib, sap.ui.commons,sap.ui.table, sap.ui.layout, sap.ca.ui"
data-sap-ui-xx-preloadlibcss="!sap.ca.common.uilib"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-xx-bindingSyntax="complex">
</script>
instead of:
script src="resources/sap-ui-core.js" type="text/javascript"
id="sap-ui-bootstrap" data-sap-ui-language="en"
data-sap-ui-libs="sap.m,sap.ca.common.uilib, sap.ui.commons,sap.ui.table, sap.ui.layout, sap.ca.ui"
data-sap-ui-xx-preloadlibcss="!sap.ca.common.uilib"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-xx-bindingSyntax="complex">
but nothing changes.
It only changes if I use ?sap-language=EN url paramteter, which I'd like to avoid.
btw. I use 1.22.4 version of SAPUI5.
Best regards
Tomasz Sobkowiak
I finally managed to fix the issue. I've added the data-sap-ui-xx-supportedLanguages="en" parameter, and now everywhere in my app is english language. I know that this is an experimental feature, so I would be grateful for a stable solution.
Moreover to ignore URL parameters I've used data-sap-ui-ignoreUrlParams="true".
Best regards,
Tomasz Sobkowiak
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.