function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to convert locale to language value?



I want to populate the current user's language field in one custom field in object.For that I'm querying the languagelocalekey from user object and assign the value to custom field


Eg:Cuobject__c cu=new Cuobject__c;


But still I'm getting the locale(en_US) instead of English.any idea to convert locale to language value.


Can anyone suggest me solution for this



Bhawani SharmaBhawani Sharma
I am not sure if there is already any standard function for this, but what I can suggest is, you can create a custom setting where you can have key and Value fields. Key will be you Languagelocalekey(en_US) and value will be English.
Now whenever you want to populate language, fetch custom setting and set value.
This will help you

The values for Language are stored like this in salesforce. You see the label 'English' in the User Interface but the value for is actually stored as 'en_US'. Similarly for other languages. I thnk you should go by what Bhawani is suggesting.