How to access the currently selected language from within controller?

How does one access the currently selected language of the logged in user (in cases where you provide a selection of languages/locales for the user to select inside the Cuba application) from within a controller for example?

I want to be able to write logic like:

if (currentlySelectedLanguage == "English") {
  .. do something...
} else if (currentlySelectedLanguage == "German") {
  .. do something...
} else if (currentlySelectedLanguage == "Russian") {
  .. do something...
} else if (...) {
  .. etc...
}

I looked at the help documentation for localization, but I might be missing the obvious.
Thanks

Hey!

Use this method: userSessionSource.getLocale().

1 Like

Hi,
You can find the code example in the following documentation: Examples of Date and Number Formatting in the Application Code - CUBA Platform. Developer’s Manual

2 Likes

Great, much appreciated, thanks guys!