In short, can I use in python many .mo
files for the same language in the same time?
In my python application, I need to use gettext
for I18N. This app uses kind of a plug-in system. This means you can download a plug-in and put it in the appropriate directory, and it runs like any other python package. The main application stores the .mo
file it uses in let's say ./locale/en/LC_MESSAGES/main.mo
. And the plug-in nr 1 has its own .mo
file called plugin1.mo
in that same directory.
I would use this to load the main.mo
I18N messages:
gettext.install('main', './locale', unicode=False)
How can I install the others too, so that all the plug-ins are translated the way they should be?
The solutions I thought of:
Should I gettext.install()
in each package's namespace? But this would override the _()
defined previously and mess the future translations of the main application.
Is there a way to combine two .mo
files in one (when a new plug-in is installed for example)?
At runtime can I combine them into one GNUTranslation
object? Or override the default _()
method that is added to the global namespace? Then, how would I go with that option?
Instead of _('Hello World')
, I would use _('plugin1', 'Hello World in plug-in 1')
Note: The application is not supposed to be aware of all the plug-ins to be installed, so it cannot already have all the messages translated in its main.mo
file.