Sdry, I have wanted to do exactly this ever since Custom Settings came out. The problem, though, is that there is no Apex API for Custom Labels (click the link to vote for the idea for it!), so Custom Labels cannot be dynamically retrieved or requested within Apex. However, it CAN, as of Spring 12, be done in Visualforce, using Dynamic Components.
Here, I think is what you are looking for in Apex (that cannot yet be done):
Custom Settings + Custom Labels IN APEX (**not yet possible**)
// Get the stored Custom Setting record for User Preferences
User_Prefs__c p = User_Prefs__c.getInstance(UserInfo.getUserId());
// Get the stored ISO Code
String isoCode = p.ISO_Code__c;
// Get the running user's language
String languageKey = [
select LanguageLocaleKey from User
where Id = :UserInfo.getUserId()
limit 1
].LanguageLocaleKey;
// Get the translation of the ISO Code corresponding to this user's language
// **THIS IS NOT POSSIBLE YET IN APEX**
String translatedCode = System.Label.getLabel('ISOCode_'+isoCode).getTranslation(languageKey);
And here would be an equivalent if you are using Visualforce:
Custom Settings + Custom Labels IN VISUALFORCE (possible right now)
/* APEX CONTROLLER */
public class Controller {
public String getStoredISOCode() {
// Get the stored Custom Setting record for User Preferences,
// and return the ISO code
return User_Prefs__c.getInstance(UserInfo.getUserId()).ISO_Code__c;
}
}
/* VF PAGE */
<apex:page controller="MyController">
<b>ISO Code</b>{!storedISOCode}
<b>Translated</b>{!$Label['ISOCode_' & storedISOCode]}
</apex:page>
@Ashish: Alternately, you should be able to create a Visualforce page which will emit JSON data. Within page you can place all labels and merge fields to emit label values (in logged-in user's language). This can also avoid creating a different custom setting/ object to store values and fully leverage usage of Custom labels for translated values.
Something like:-
VF Page:-
{
"Invoice" : "{!$Label.Invoice}",
"PurchaseOrder" : "{!$Label.PurchaseOrder}"
}
Accessing this web page via mobile app (as a REST API) should not be an issue.
Best Answer
It simply means:
Difficult to understand; maybe it would be clear when you try the example.
Output on click of save when email is empty (code at the end)-
Note: Error message for second and third sections/input are same (as apex:pageMessage doesn’t show duplicate message), default message with field's label; only difference is in #3 we have empty label hence it doesn't show a field label because its expecting us to add.
Code for illustration: