⏰ Time to Implement: 20 minutes
🤷♀️ Why: Translate more than 2 languages in bulk if you hit the 2-language auto-translate limit
🔗 Important Links: You'll need Google Docs and the Script here.
Within the Shopify Translate and Adapt app which allows you to translate your store and connect languages to Markets i.e. show French for visitors from France and English to visitors from the UK - there is a pesky limit - you can only auto-translate a maximum of two languages. That being said, you would still be able to manually translate content if you hit your limit. Here is how to manually translate your content in bulk using the Google Translate API inside Google Sheets
1. Choose the language you want to translate and click on Auto-translate
2. If you see the below message, you have reached your limit and will need to manually translate - continue following the steps below.
If you do NOT see the below message you may not have reached the limit and you can proceed with the auto-translation (yay)
3. Click on Manage to open the 'Languages' settings
4. Click on Export
5. Select the Language you want to export and translate
6. Click on Export
7. Upload the CSV you exported to a Google Drive
8. Click on Open with
9. and select Google Sheets
10. Instead Google Sheets click on Extensions from the menu
11. Click on Apps Script
‼️ Copy and paste the Script below
function translation(text, froml, tol) {
// Check if source and target languages are the same
if (froml === tol) {
return ''; // Return blank if source and target languages are the same
}
// Check if source text is only a number
if (!isNaN(text)){
return ''; // Return blank if source text is only a number
}
// Convert text to string if it's not already
var inputText = String(text);
// Extract the Liquid code by matching text inside double curly brackets
var liquidCode = inputText.match(/{{\s*[\w\.]+\s*}}/g);
// Replace the Liquid code with a placeholder for translation
var cleanedText = inputText.replace(/{{\s*[\w\.]+\s*}}/g, '[[liquid_code_placeholder]]');
// Translate the cleanedText
var translatedText = LanguageApp.translate(cleanedText, froml, tol, {contentType: 'html'});
// Restore the Liquid code in the translated text
if (liquidCode) {
liquidCode.forEach(function(code, index) {
translatedText = translatedText.replace('[[liquid_code_placeholder]]', code);
});
}
return translatedText;
}
12. Delete the default code
13. Paste the code you copied above text into the text area
14. Click on Deploy…
15. Click on New deployment
16. Click on Enable deployment types
17. Click on Web app
18. Type "translation"
19. Click on Who has access…
20. Click on Anyone
21. Click on Done
22. Select the first cell in the column for 'Translated Content'
23. Type the formula '=translation
24. Select the cell with the content you want to translate then add a comma (,)
25. Type the language code for the language you are translating from.
In this case it is English so we have used "en", end with a comma (,)
26. Next select the cell that contains the language you are translating to
In this example it is Polish (pl) in cell D2
27. Click enter to run the formula and translate
If you see the translation in cell H2 - great! If you don't see the translation, you see 'Error' please check your formula.