Enhancing Multilingual Content on Shopify and Google Docs

Open Translate & Adapt in Shopify

  1. 1. Choose the language you want to translate and click on Auto-translate

    Choose the language you want to translate and click on Auto-translate
  2. 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)

    If you see the below message, you have reached your limit and will need to manually translate - continue following the steps below.
  3. 3. Click on Manage to open the 'Languages' settings

    Click on Manage to open the 'Languages' settings
  4. 4. Click on Export

    Click on Export
  5. 5. Select the Language you want to export and translate

    Select the Language you want to export and translate
  6. 6. Click on Export

    Click on Export
  7. 7. Upload the CSV you exported to a Google Drive

    Upload the CSV you exported to a Google Drive
  8. 8. Click on Open with

    Click on Open with
  9. 9. and select Google Sheets

    and select Google Sheets
  10. 10. Instead Google Sheets click on Extensions from the menu

    Instead Google Sheets click on Extensions from the menu
  11. 11. Click on Apps Script

    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;

}

  1. 12. Delete the default code

    Delete the default code
  2. 13. Paste the code you copied above text into the text area

    Paste the code you copied above text into the text area
  3. 14. Click on Deploy…

    Click on Deploy…
  4. 15. Click on New deployment

    Click on New deployment
  5. 16. Click on Enable deployment types

    Click on Enable deployment types
  6. 17. Click on Web app

    Click on Web app
  7. 18. Type "translation"

    Type "translation"
  8. 19. Click on Who has access…

    Click on Who has access…
  9. 20. Click on Anyone

    Click on Anyone
  10. 21. Click on Done

    Click on Done

Go back to your Google Docs

  1. 22. Select the first cell in the column for 'Translated Content'

    Select the first cell in the column for 'Translated Content'
  2. 23. Type the formula '=translation

    Type the formula '=translation
  3. 24. Select the cell with the content you want to translate then add a comma (,)

    Select the cell with the content you want to translate then add a comma (,)
  4. 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 (,)

    Type the language code for the language you are translating from.
  5. 26. Next select the cell that contains the language you are translating to

    In this example it is Polish (pl) in cell D2

    Next select the cell that contains the language you are translating to
  6. 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.

    Click enter to run the formula and translate
  7. 28. You can now click and drag the formula down to complete the translation for all rows and conrtent

    You can now click and drag the formula down to complete the translation for all rows and conrtent
  8. 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.

    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.