0

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?

1

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.

0

As far as I know this feature is not available in lightning today

In VisualForce you can set the language with <apex:page language="en-us">, and if you want to connect that to an apex attribute - that's easy.

You can see also other post that requests that: Set language / locale globally for a Lightning Application

So as of today, what you can do is:

  1. Use custom labels with their language translations.

  2. arrange that your language selection picklist would change the actual user language, then after page refresh, all fields would get their translated values.

  • For now, I just had a few fields so I saved those values in a custom metadata object and separated them based on a language pick-list and retrieved them using a SOQL Query. Am not sure if it's an ideal solution but it works. – Sankeerth R. Aug 15 '17 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.