I have two different language i.e English and German in my web app and user can change the language in application through a select box. Initially i am getting preferred language from the back-end and i am setting locale of the core as follows.
sap.ui.getCore().getConfiguration().setLanguage("//according to whatever is coming from back-end")
Now lets say initial language is English, if user open a control i.e sap.m.datepicker, calendar is being displayed in English. If user changes the language to German from the application i am again changing the language in the core as shown below:
sap.ui.getCore().getConfiguration().setLanguage("de-DE")
Now if user opens that same datepicker, it is being displayed in English instead of German and if user opens some another control or datepicker it is being rendered in German.
Page is not getting refreshed while changing the language in app.
Please suggest me a solution to dynamically change the locale of the controls.
Maybe my answer here helps a little.
The problem is that in many cases, maybe even in most cases, the standard UI5 controls detect the language only once when they get loaded. Very often, the control developers did not implement a "dynamic change" of the language. If you check the link I mentioned above you will see that there are ways to react on language changes, but very often this is not implemented for whatever reason.
However, I'm afraid to tell you that in your case the standard control might not support dynamic language changes out of the box (but I did not check the code). Also, it seems that the UI5 guys at SAP do not consider this as a bug (see this github issue). Such a pity...
I would suggest you use sap.ui.core.Core.attachLocalizationChanged(fnFunction, oListener) and add this to the onInit function of your controller.
From this, in your fnFunction rebuild the controls where you require the locale changes to be dynamic.
example:
onInit: function(oEvent) {
sap.ui.getCore().attachLocalizationChanged(this._handleLocalizationChanged, this);
},
_handleLocalizationChanged: function() {
// ... Some logic to re-build / set locale for the dynamic controls.
}
This is my interpretation of what should be done based on the information in the api
Related
I have a problem in french translation of an application. The application is translated completely fine, but when we run an Interactive Report, the string showing current filter is still in English, not in French. See the following screen shot
Is there a way that we can translate the string showing filter text (in this example "Running" and "Highlight Failed")? Can someone please help with this?
Thanks in Advance.
Interactive Report and Interactive Grid settings are being set in the frontend rather than the backend where all the translation logic is located. Therefore, I don't think it is possible to do this with the standard APEX translation methods.
If you have a basic Report with only little customatization and you really need to translate these filters, I would suggest to create two Reports in the Backend, one for the english version, one for the french version, and use the language application item (usually FSP_LANGUAGE_PREFERENCE) to display one or another.
If you have a complicated report with several private reports or heavy customization, I would advise against this solution and just use both language to name your Report settings like you did in your example.
Another option would be to use Javascript to rename the display filter. Try $('.a-IG-controlsLabel[data-setting="highlight"]') to select the appropriate items. However, it will be kind of hard to find the correct event handlers to trigger this at the right moment.
I'm trying to make the language switcher to work, I have already made all menus for each language I was gonna use, but when I enable this module, It just shows me the name of the module(when I put it to show), not the flags. What should i do?
I lost a full day of my life with this topic.
The issue was that language tag was badly setup in System -> Language Manager -> Content
For example for French I had fr when it should have been fr-FR
After that I had to rebuild/redo all the Language assignments for French on Pages, categories, menus, template.
The flag finally showed up...
It's an old question but, telling from the comments, a recurring problem. Seems like there can be multiple root causes. One thing to check is also that you have marked the default menu item for each language. If not, the corresponding language does not show in the language switcher.
Found that You need to set a default homepage that can be in hidden menu (and redirect from later) to Language "All"
But then also go to each menu and make the page 1 language and also Homepage.
So for me I have now 3 language homepages menu items. All, En, De
How did I discover this:
I needed to turn on a module in the Admin:
Language Status Administrator Module
This makes a small button bottom left in the Admin, and modal points out 3 different topic per language installed, told me I had not any homepages, and so would get no flags. (Thanks to Per on Joomla forum answer from 2016)
Happy fixing.
you need to set up the languages in the Language Manager? under extensions..
and make sure you published the "System - Language Filter" plugin.
Plugins -> System - Language Filter -> Automatic Language Change -> No
This will prevent automatic language changin which is often reason for this
Is there a way to change the current language to another one at runtime ?
For example: be able to switch when a button is clicked or when starting the app, get the user language and switch.
How to tell the plugin to check the user language at startup ?
Thanks in advance for your help.
Is there a way to change the current language to another one at runtime ?
yes, call builder.LoadResources(whichLanguage) on your MvxTextProviderBuilder.cs
For example: be able to switch when a button is clicked
The UI framework isn't really setup to perform switching live. When you switch between languages then the new JSON resource files will all be loaded OK - but existing displayed text will not be updated. This is a bit like most mobile operating systems - if you want to switch language you often need to reboot!
If you wanted to add dynamic switching then you'd have to find a way to tell the UI to completely refresh all text - I suspect this wouldn't be hard to do, but it might require some manual coding on every page/View which has already been created and displayed :/
or when starting the app, get the user language and switch.
This is a much more straight-forward way to do i18n. It's normally OK because MvvmCross mainly targets phones - and phones are normally single user devices which don't switch languages very often.
You could, for example, use some variable (e.g. System.Globalization.CultureInfo.CurrentUICulture) to work out the best language to display.
Or you detect on load whether the user has picked a language yet - if they have, then show HomeViewModel - if they haven't then show a LanguagePickerViewModel - this is what we did in StarWarsKinect - the StartNavigationObject is a perfect place for this sort of logic!
How to tell the plugin to check the user language at startup ?
Currently, you'll have to code this logic as part of your app startup.
I'd definitely be open to providing an improved plugin on this - perhaps with a demo!
If you are looking at i18n, then one alternative implementation to consider is Vernacular - the team at Rdio have a very good offering for Mono and MS platforms - https://github.com/rdio/vernacular
I need to create an extension that would change my browser locale on a mouse click.
I'm developing a bilingual web app, and I'm setting the i18n messages according to the browser locale. But this requires me to get to the wrench, then under the hood, then languages, then the drag&drop thing to switch the locale. Searching the chrome extensions didn't bring any results. I'm now trying to make a chrome extension which would make this a click or two closer, but I'm having troubles doing that.
I can get to the list of accepted languages with chrome.i18n.getAcceptLanguages(callback), but I don't know how to set the locale (or reorder or whatever).
Can somebody tell me which function ot use or even if there already is such an extension?
Well, does this help?
http://www.chromium.org/developers/design-documents/extensions/proposed-changes/apis-under-development/preference-api
Use cases
It allows extensions to read and write the browser preferences. Given accept languages as an example, page translation extension and dictionary extension will need to get the accept languages from the browser and use them as the targeted languages for page or word translation.
It lists:
chrome.preferences.
void getAcceptLanguages(void callback(String acceptLanguages))
void setAcceptLanguages(Value newAcceptLanguages)
void appendAcceptLanguage(Value acceptLanguage)
I'm using MVVM Light in my Windows Phone 7 application. The application is to be used in English and Spanish. Users can select a different language during runtime. I'm localizing the application using resource files. I've already been able to make the localization works, but only when I change the language from Settings. In the main page, I have a list for users to select the language during runtime, I'm setting the selected language to Thread.CurrentThread.CurrentCulture, but the text strings in the interface don't get updated. I have a set of properties in the ViewModel that I'm binding to the View to set the labels of the control, but something is missing. I've been reading that I need to implement the INotifyPropertyChanged in the ViewModel to make this works, but I don't know how to exactly do that nor if there is a different better way to implement this case using MVVM Light. Could anybody help me here please?
Hum, I wrote a blog post about it sometimes ago ( http://wp7wonders.wordpress.com/2010/10/17/localize-a-windows-phone-7-application/ - read the comments too!). The main point is that you have an object between the resource files and your viewmodels which allow to change the dynamically the language.