Changing the entire GUI language, all at once
In this recipe, we will change all of the GUI display names, all at once, by refactoring all the previously hardcoded English strings into a separate Python module and then internationalizing those strings.
This recipe shows that it is a good design principle to avoid hardcoding any strings that our GUI displays but to separate the GUI code from the text that the GUI displays.
Note
Designing our GUI in a modular way makes internationalizing it much easier.
Getting ready
We will continue to use the GUI from the previous recipe. In that recipe, we had already internationalized the title of the GUI.
How to do it…
In order to internationalize the text displayed in all of our GUI widgets, we have to move all hardcoded strings into a separate Python module, and this is what we'll do next.
Previously, strings of words that our GUI displayed were scattered all over our Python code.
Here is what our GUI looked like without I18N
:
GUI_Refactored.py
Every single string...