Skip to content

sf_translate provide tool to translate and convert translate file related to salesforce products.

License

Notifications You must be signed in to change notification settings

syunyama/sf_translate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Salesforce Translate

This tool is used to translate file for 3 types below.

  1. Export Data Translation Files (xml:data)
  2. Localize Store Labels (xml:component)
  3. Translate metadata file from CustomLabels to Translations (xml:label)
  4. Translate metadata file from StandardValueSet to StandardValueSetTranslation (xml:standard_value)
  5. Translate StandardValueSetTranslation files to another language (xml:standard_value_convert)
  6. Translate Translations files to another language (xml:translation_convert)
  7. Translate property file like SFRA template localization (property:basic)

Supported Translator

Install dependencies

pip3 install -r requirements.txt

Utilize

Make command in local

python3 setup.py develop

Uninstall command from local

python3 setup.py develop -u

Make library in local

pip3 install -e .

Uninstall library from local

pip3 uninstall sf_translate

Basic usage

python3 command.py {arguments}

OR if you already utilized as command

sf_translate {arguments}

Commands

For data type

sf_translate xml:data -i sample/data/Source_Product2_sample.xlf -o sample/result/RESULT_Source_Product2_sample.xlf -tl en_US -sl ja -k {api key}

For component type

sf_translate xml:component -i sample/component/components_ja_en-US_sample.xlf -o sample/result/RESULT_components_ja_en-US_sample.xlf -k {api key}

For label type

sf_translate xml:label -i sample/label/CustomLabels.labels-meta.xml -o sample/result/ja.translation-meta.xml -tl ja -k {api key}

For standard value

sf_translate xml:standard_value -i sample/standard_value/LeadSource.standardValueSet-meta.xml -o sample/result/LeadSource-ko.standardValueSetTranslation-meta.xml -tl ko -k {api key}

For standard value convert

sf_translate xml:standard_value_convert -i sample/standard_value_convert/LeadSource-ja.standardValueSetTranslation-meta.xml -o sample/result/LeadSource-ko.standardValueSetTranslation-meta.xml -tl ko -k {api key}

For translation convert

sf_translate xml:translation_convert -i sample/translation_convert/ja.translation-meta.xml -o sample/result/ko.translation-meta.xml -tl ko -k {api key}

For property type

sf_translate property:basic -i sample/property/account.properties -o sample/result/address_ja_JP.properties -tl ja -k {api key}

Use as Python library

import os
from sf_translate.services.translator import DeepLTranslator, GoogleTranslator
from sf_translate.services.editor import LabelXMLEditor


def main():
    translator = DeepLTranslator("Your DeepL API Key")
    # OR
    # translator = GoogleTranslator("Your Google Cloud API Key")
    editor = LabelXMLEditor(
        translator = translator,
        input_path = os.path.abspath("sample/label/CustomLabels.labels-meta.xml"),
        output_path = os.path.abspath("sample/label/ja.translation-meta.xml"),
        target_lang = "ja",
        source_lang="en_US",
    )
    editor.translate()


if __name__ == "__main__":
    main()

Notes

  • Some non pure string value like JSON, HTML and so on can not be translated properly.

About

sf_translate provide tool to translate and convert translate file related to salesforce products.

Topics

Resources

License

Stars

Watchers

Forks

Languages