Translation Tools
Topics
- Install Kural CLI
- Using Kural CLI to translate
- How to prepare translation TSV from STF file
- Using CLI you can convert the XLF file into TSV
- Using CLI to fill-in Salesforce translation file (STF)
Install
# linux and mac
sudo npm i -g kural
# windows
npm i -g kural
Chrome Driver
- Download the Chrome Driver file and put this in your PATH
Using Kural CLI to translate
kural i18n:translate
-
Translates a given sentence into various languages and provides verification Google Translate URL (optionally) to verify the translation work
-
Uses Google Translate
# Translate to French
kural i18n:translate -i 'Good Morning, Friends!' -f 'en' -t fr
Bonjour les amis!
# Translate to Tamil
kural i18n:translate -i 'Good Morning, Friends!' -f 'en' -t ta
காலை வணக்கம் நண்பர்களே!
# Translate to Telugu
kural i18n:translate -i 'Good Morning, Friends!' -f 'en' -t te
శుభోదయం మిత్రులారా!
# Translate to Marathi
kural i18n:translate -i 'Good Morning, Friends!' -f 'en' -t mr -g true
सुप्रभात, मित्रांनो!
# Translate to Japanese and launch google translate to verify the translation work
kural i18n:translate -i 'Good Morning, Friends!' -f 'en' -t ja -g true
おはようございます、友達!
-
Translation verification
How to prepare translation TSV from STF file
- Demo showing how to do the export - PDF
- exported-2.stf is the input file you got from Translation workbench export
sfdx mohanc:i18n:stf:prep -i exported-2.stf > exported-2.stf.tsv
exported-2.stf.tsv
Using CLI you can convert the XLF file into TSV
-
If you exported the XLF file in the translation workbench you will have the information about the max width/size of the translation allowed for each key.
-
stf2tsvHtml.xsl used here
sfdx mohanc:xml:transform -i img/exported-2.xlf -t xsl/stf2tsvHtml.xsl
Above command will open a HTML page with TSV file loaded in a textarea. You can cut and paste the content of the textarea to create a TSV file.
- If you want to view the XLIFF file as a TSV page:
sfdx mohanc:xml:transform -i img/exported-2.xlf -t xsl/stf2tsv.xsl
=== Writing the output into file : img/exported-2.xlf.out.xml.html ===
- If you want to view the XLIFF file as a HTML page:
sfdx mohanc:xml:transform -i img/exported-2.xlf -t xsl/stf2html.xsl
=== Writing the output into file : img/exported-2.xlf.out.xml.html ===
Using CLI to fill-in Salesforce translation file (STF)
NOTES
CLI allows progressive filling of stf with translated files
STEPS
- Export STF file for a bilingual (using Translation workbench) - say our case it is French (FR)
- Our file say: exported.stf
- You have translated the keys in this STF file and have the translated-1.psv (Pipe Separated Value file)
- Create the filled value stf file batch-1.stf using this command:
sfdx mohanc:i18n:stf:fill -i exported.stf -t translated-1.psv > batch-1.stf
cat translated-1.psv
1|ButtonOrLink.Account.Billing|Billing|Facturation
2|CustomField.Account.CustomerPriority.FieldLabel|Customer Priority|Priorité du client
batch-1.stf
- Now another translation team has provided you translated-2.psv
- You can apply this translation on top of batch-1.stf, using this command
sfdx mohanc:i18n:stf:fill -i batch-1.stf -t translated-2.psv > batch-2.stf
cat translated-2.psv
1|ButtonOrLink.Opportunity.DeliveryStatus|Delivery Status|Statut de livraison
2|CustomField.Account.NumberofLocations.FieldLabel|Number of Locations|Nombre d'emplacements
batch-2.stf
- and so on...
- You can load (import) the final stf file to the org in translation workbench
- If you export again you will see the results of your translations: