Once in a while as a data scientist, your job may be to produce a report that you could email to stakeholders or share through the intranet. Word documents may seem a bit old school, but there are still cases when using them is the shortest route to this goal. Whenever automation is discussed, Python is a tool of choice. Creating an automated report using it is a rather standard skill for a data scientist.
But everything’s all fun and games until other languages show up.
In theory, preparing another language version does not seem complicated. After all, it is enough to translate individual labels and descriptions into another language and then hardcode them in the next version of the script. In practice, this simple approach is time-consuming and error-prone, especially when there is a constant need to modify some messages. Not to mention the difficulty of working with non-technical translators using this method.
This article shows how to save time by translating the Python-generated data report by using Gettext and Localazy. I’ll show you how to extract messages from the source code (Gettext), store them in separate files and how to make them available in a collaborative translation tool (Localazy). Also, you will learn how to deal with difficulties in translating f-strings.