D
D
DiRx2016-05-04 14:21:48
Python
DiRx, 2016-05-04 14:21:48

Module for program localization?

Good afternoon!
For example, we are talking about backend, and there is a function

def getError(user):
return _('Error', lang=user.get_lang())

In the example, I seem to be using gettext, but, as I understood from a quick search, it works based on the locale set on the PC, and I need myself to explicitly indicate which language to use. And as far as I understand, this is not possible in gettext.
I ask you to suggest a system that would allow this to be done, I don’t want to write my bike =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2016-05-04
@DiRx

Misunderstood, in gettext this is possible.

def getError(user):
    local_gettext = gettext.translation('myapplication', languages=[user.get_lang()])
    _ = local_gettext.ugettext
    return _('Error')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question