stratoflow

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:

Building a new application or extending your development team?

🚀 We're here to assist you in accelerating and scaling your business. Send us your inquiry, and we'll schedule a free estimation call.

Estimate your project
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!

Building a new application or extending your development team?

🚀 We're here to assist you in accelerating and scaling your business. Send us your inquiry, and we'll schedule a free estimation call.

Estimate your project

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

testowy tekst

Martyna

Senior