Object-oriented gettext
Victor Porton
porton at narod.ru
Thu Feb 1 02:06:25 EST 2018
Victor Porton wrote:
> I want to write a multiuser application which uses multiple languages (one
> language for logging and a language per user).
>
> https://docs.python.org/3/library/gettext.html describes a procedural
> gettext interface. The language needs to be switched before each gettext()
> call.
>
> I want an object oriented interface like:
>
> english.gettext("Word") == "Word"
> russian.gettext("Word") == "Слово"
>
> That is, I do no want to write any language-switching code, but the
> language should depend on the object (like "english" and "russian" in the
> above example).
>
> What is the best way to do this?
>
> Should I write an object-oriented wrapper around gettext package?
Oh, I see that gettext.translation() seems to do the job.
--
Victor Porton - http://portonvictor.org
More information about the Python-list
mailing list