Enhancing Multilingual Content on Shopify and Google Docs
Open Translate & Adapt in Shopify
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

Go back to your Google Docs
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.

28. You can now click and drag the formula down to complete the translation for all rows and conrtent

29. Note: If you see an error message like the below, you have reached the API limit for the day. You will need to translate your content in batches so come back tomorrow to complete the process.
