[SalesForce] Lightning Component: Select locale language based on a picklist value

I created a form using lightning components. So, in lightning components is there a way to change the labels of the fields based on a language selected through a picklist by the user?

Best Answer

if you are using VF page then it is necessary to explicitly set the language parameter.

However if you are using lightning components this is done automatically, what happens is that for instance url parameter "?language=nl_NL" is being picked up and if you are using a custom label in your component it will automatically show the translated label value in dutch(in this case).

So what you need to do is just translate the custom labels, include them in you component e.g. {!$Label.c.ErrorMessageWC} and the platform will handle that the right translation is shown.

url parameter can be set in different ways this depends on your requirements just be sure to have it.

I had the same issue, hope this helps.

Regards, Zoran.

Related Topic