If you integrate Localazy CLI into your CI/CD, you may want to trigger some actions based on how complete the translation of certain languages is.

It's helpful in many situations:

  • You can only include fully translated languages.
  • You may want your CI/CD pipeline to fail when highly important languages are not fully translated.
  • You can enable languages that have already reached a certain completion level.

⌨️ How to do it? 🔗

For this purpose, Localazy CLI comes with the languages command, and requesting the data in pure CSV format is the preferred way for your own scripting.

Assuming that read and write keys are provided, you can just invoke localazy languages --csv to get results like this:

locale,total,untranslated,need_review,need_improvement,source_changed,published,source
zh#Hans,2134,2133,0,0,0,true,false
akz,2134,2134,0,0,0,false,false
am,2134,2134,6,0,0,false,false
ar,2134,2133,19,0,0,false,false
ar_EG,2134,2134,29,0,0,false,false
ar_MA,2134,2134,2,0,0,false,false
cs,2134,611,0,0,3,true,false
cs_CZ,2134,2132,19,0,0,false,false
ar_EG#Syrc,2134,2134,1,0,0,false,false
en,2134,159,152,0,11,true,false
xxa,2134,0,0,0,0,true,true

As you can see from the output above, my source language is xxa, which is our custom code for Developer English. Certainly, I want English to be translated fully, and a simple bash script can do the trick for me:

#!/bin/bash
while IFS="," read -r locale total untranslated need_review need_improvement source_changed published source
do
  if [ "$locale" == "en" ]; then
    if [ $untranslated -ne 0 ] || [ $need_review -ne 0 ] || [ $need_improvement -ne 0 ] || [ $source_changed -ne 0 ]; then
      echo "English is not fully translated!"
      exit 1
    else
      echo "English is correct and ready."
      exit 0
    fi
  fi
done < <(localazy languages --csv)

echo "English not found!"
exit 127

It invokes Localazy CLI, analyzes the response, and looks for English to check for its status. The script exits with code corresponding to the results:

  • 0 - Everything is okay; English is fully translated.
  • 1 - English is not fully translated.
  • 127 - English cannot be found in the results from Localazy CLI.

And that's it. This is a simple yet effective solution to control your pipelines based on the translation status.

💖 You might also like 🔗