We need a way to copy English translations of picklist labels into other languages. Given a picklist on the Opportunity object with values Y and N translated as follows:
Value EN_us DE FR
Y Yes Ja
N No Nein
We want a scheduled apex job to fill in missing labels in French with "Yes" or "No" from the English translation until such time as someone overwrites them manually with "Oui" and "Non".
Why? Because if the label is missing in French then SalesForce displays "Y" and not "Yes". In this example it might still be understandable for an French User that "Y" means Yes but in other examples, with picklists containing technical keys it would not be.
I know how to query the labels in my current language and get "Yes" but how to I query and set labels in a different language? Ideally I want to do this in apex and not by deploying files.
List<Schema.PicklistEntry> vals = Opportunity.SomeField__c.getDescribe().getPicklistValues();
for (Schema.PicklistEntry val: vals) {
system.debug(val.getValue()+'='+val.getLabel());
// 1. How can I do val.getLabel('FR') ?
// 2. How can I do val.setLabel('FR', 'Yes') ?
}
I have tried looking at the .objectTranslation files in the IDE but they are empty even though we have translated values. For example Opportunity-de.objectTranslation
contains simply:
<?xml version="1.0" encoding="UTF-8"?>
<CustomObjectTranslation xmlns="http://soap.sforce.com/2006/04/metadata"/>
even though we have several translated picklist labels in German on the Opportunity object.
UPDATE: Using Ant (or Force.com IDE) to retrieve translations always returns empty files even though we have picklists translated.
<sf:bulkRetrieve ... metadataType="CustomObjectTranslation" retrieveTarget="retrieved"/>
returns empty files (e.g. Opportunity-no.objectTranslation
):
<?xml version="1.0" encoding="UTF-8"?>
<CustomObjectTranslation xmlns="http://soap.sforce.com/2006/04/metadata"/>
Same story for metadataType="Translations"