Global UI Action to switch Language ... ?!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 05:29 AM
Hi Experts,
to speed up the change of the language for admins; i wanted to quickly add an UI Action to reduce the manual steps ...
Somehow my quick script did not work as expected ... so any hint or better best practice for me?
We have german and english set up only ...
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 06:01 AM
If it's only for admins, then it raises other questions in my head. Example:
Is this really the most important thing we should be working on if it's only for a small group of people?
I'll leave that up to you and your team to figure out priorities on which issues/features/stories to work on next.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 05:59 AM
Hi Chuck,
As you said but for few places, we need such customizations for example, we have our profile page in CMS where I have added a language switch for end users through this.
This certainly helps a lot but placing it in every form would be a really bad idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 05:33 AM
Hi Vemfim,
Please use below code in your UI action
var util = new I18nUtils();
util.setLanguage(lang);
where lang is the language code. English- en, german - de.
The OOB feature uses the same script as I18nUtils is the utility which updates the user's preference for selected language.
Please mark the response correct/helpful based on the impact.
Thanks
Gaurav

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 05:48 AM
Sounds good!
Just some pieces missing.
Need to check if en right now then switch to de ... and the other way around ...
SO I first need to get the language code .. like ...
var language = g_user.getClientData("loginlanguage"); .... ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 05:53 AM
g_lang in client script gives the current language of the logged in user.
Tried and tested.
You can use it instead of session.
In server script, you can use gs.getUser().getLanguage() for the same.
Thanks
Gaurav