2

I'm trying to retrieve the translations in translation workbench to add to Stash. My sample .xml file is below.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
    <members>Sample_Object__c-es_CO</members>
    <name>CustomObjectTranslation</name>
</types>
    <version>37.0</version>
</Package>

I am able to successfully retrieve the object, but the file does not contain any of the translations that I have added. I have verified that I am using the correct sandbox, I verified the object name, I verified that I added the translations in my sandbox, but still no luck.

The sample output in the file is below:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObjectTranslation xmlns="http://soap.sforce.com/2006/04/metadata">
    <caseValues>
        <plural>false</plural>
        <value><!-- Sample Object --></value>
    </caseValues>
    <caseValues>
        <plural>true</plural>
        <value><!-- Sample Object --></value>
    </caseValues>
    <gender><!-- Feminine --></gender>
    <nameFieldLabel><!-- Sample Object Name --></nameFieldLabel>
</CustomObjectTranslation>
  • 1
    Translation is retrieved only for those parts of objects, which are included in package xml (similar with permissions sets or profiles). To get more translations, please include sObject itself, and page layouts. – kurunve Apr 28 '17 at 19:58
  • kurunve, if you want to add this as a solution, I will mark it as the answer. – Kevin Apr 28 '17 at 20:28
2

Object's translations are retrieved only for object's custom metadata, which is included into package.xml For example, if package xml contains only one custom field and one page layout, then translation will be returned for that field only

For example:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Sample_Object__c-es_CO</members>
        <name>CustomObjectTranslation</name>
    </types>
    <types>
        <members>Sample_Object__c.Sample_Field__c</members>
        <name>CustomField</name>
    </types>
    <version>37.0</version>
</Package>

That will return Sample_Field__c translation as result.

In case if entire sObject needs to be translated, then package.xml should be like next:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Sample_Object__c-es_CO</members>
        <name>CustomObjectTranslation</name>
    </types>
    <types>
        <members>Sample_Object__c</members>
        <name>CustomObject</name>
    </types>
    <version>37.0</version>
</Package>

P.S. Very interesting behaviour, found by me: In case if package.xml contains custom object from managed package, and also page layout from managed package, together with non-English language, may cause translation for page layout name returned without prefix . For example:

<layouts>
    <layout>Sample Object Layout</layout>
    <sections>
        <label><!-- Address Information --></label>
        ...
    </sections>
    ...
</layouts> 

Problem is that it may fail on deployment. Fix is easy -- add prefix manually before deployment:

<layouts>
    <layout>MY_AMAZING_PACKAGE__Sample Object Layout</layout>
    <sections>
        <label><!-- Address Information --></label>
        ...
    </sections>
    ...
</layouts>

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.