This tool is used to translate file for 3 types below.
- Export Data Translation Files (xml:data)
- Localize Store Labels (xml:component)
- Translate metadata file from CustomLabels to Translations (xml:label)
- Translate metadata file from StandardValueSet to StandardValueSetTranslation (xml:standard_value)
- Translate StandardValueSetTranslation files to another language (xml:standard_value_convert)
- Translate Translations files to another language (xml:translation_convert)
- Translate property file like SFRA template localization (property:basic)
- DeepL
- Get API Key following this instruction
- Google Cloud
- Get API Key following this instruction
pip3 install -r requirements.txt
python3 setup.py develop
python3 setup.py develop -u
pip3 install -e .
pip3 uninstall sf_translate
python3 command.py {arguments}
OR if you already utilized as command
sf_translate {arguments}
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}
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}
sf_translate xml:label -i sample/label/CustomLabels.labels-meta.xml -o sample/result/ja.translation-meta.xml -tl ja -k {api key}
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}
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}
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}
sf_translate property:basic -i sample/property/account.properties -o sample/result/address_ja_JP.properties -tl ja -k {api key}
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()
- Some non pure string value like JSON, HTML and so on can not be translated properly.