[SalesForce] How to translate picklist items with Metadata API

I have a picklist in my Metadata API :

<fields>
        <fullName>Test__c</fullName>
        <externalId>false</externalId>
        <label>Test</label>
        <picklist>
            <picklistValues>
                <fullName>Car</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Bus</fullName>
                <default>false</default>
            </picklistValues>
            <sorted>false</sorted>
        </picklist>
        <type>Picklist</type>
    </fields>

I would like to know if it's possible to manage translations for picklist items ? In this example, no matter user language is, it always show 'Car' and 'Bus'.

Best Answer

In the Metadata API CustomFieldTranslation has a picklistValues field of type PicklistValueTranslation[]. It has a masterLabel and translation string.

So your package.xml for the retrieve call would be something like:

<types>
    <members>*</members>
    <name>CustomObjectTranslation</name>
</types>

You will get something like:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObjectTranslation xmlns="http://soap.sforce.com/2006/04/metadata">
<!-- SNIP... -->
<fields>
    <name>LeadSource</name>
    <picklistValues>
        <masterLabel>Advertisement</masterLabel>
        <translation>Anzeige</translation>
    </picklistValues>
    <picklistValues>
        <masterLabel>Customer Event</masterLabel>
        <translation>Kundenveranstaltung</translation>
    </picklistValues>
Related Topic