The CreatorCon Call for Content is officially open! Get started here.

Global UI Action to switch Language ... ?!

Zod
Giga Guru

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 ...

9 REPLIES 9

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.


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.


Gaurav Bajaj
Mega Sage

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


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"); .... ?


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