
There are four steps to internationalizing this program: Say you have a simple "Guess the Number" game written in Python 3 that you want to translate. gettext was designed as a system for all programming languages, but we'll focus on Python in this article.
#Poedit license code software
gettext is a set of tools and file formats created in the early 1990s to standardize software internationalization (also called I18N). This is pretty much what Python's gettext module does. This would work, but you'd be reinventing the wheel. For example, if the language setting was stored in a global variable named LANGUAGE, the _() function could look like this: def _(s): and the _() function could return the translation for 'Hello world!' based on what language setting the program had.


you could change this to: print(_('Hello world!')) For example, if your program was: print('Hello world!') For example, you could replace every string in your program with a function call (with the function name being something simple, like _())) which will return the string translated into the correct language. You could hack together your own solution. And if you want your program in other languages, it gets even worse.įortunately, Python provides a solution with the gettext module. But this would mean you have two separate copies of your code, which doubles your workload every time you need to make a change or fix a bug. py file and replace any text strings you find. You could duplicate the entire code-base, then go painstakingly through each.

You've written a Python 3 program and want to make it available in other languages.
