Obtaining language of the current user

Using different languages on your page is crutial when you have a multilingual company or your partners are located on the other side of the globe. I’ve seen on various forums that some people are struggling with finding an efficient and easy way of getting the language of the current user in Visualforce page, so in today’s quick post I’m going to show you a simple way of doing just that.

So let’s start from the beginning. Each language is given its own special two letter country code, just like in this example:

  • French: fr
  • German: de
  • Italian: it
  • Japanese: ja

So the key to figuring out what language the user is using, is finding out these two letter country code. To do that in the quickest in most efficient way just use this line of code in your work:

if(UserInfo.getLanguage() == 'pl'){
//Do something
}

It’s just as simple as that. Sorry that today’s post is rather short. Next time we are going to tackle more complex problems. Stay tuned!

Comments (0)

Thanks! Your comment is awaiting moderation.

Testimonials

They have a very good company culture of their own, which gives them a real edge compared to other providers.

CEO

Leading UK system integrator

They're very skilled technically and are also able to see the bigger picture.

Managing Partner

Scalable SaaS for healthcare IoT built on Salesforce platform

They've been consistently able to deliver work on time and within budget.

CTO

High performance SaaS for financial insitutions

We are seriously impressed by the quality and broader picture of anything they do for us.

CEO

Gold trading platform

Speak with an Expert

How can we help? If you would like a member of the Stratoflow team to get in touch, please send us your message and we will contact you shortly.

Contact