gettext

vscode python gettext : Pylance reports undefined variable '_'

vscode python gettext : Pylance reports undefined variable '_' Question: In a localized program I use gettext.install() in the main modul src/testgettext.py. The documentation (python 3.10.7) says gettext.install(domain, localedir=None, codeset=None, names=None) This installs the function _() in Python’s builtins namespace… The code import gettext gettext.install("any") de = gettext.translation(‘testgettext’,localedir="src/locales", languages=[‘de’]) de.install() print(_("Selected Files:")) functions as awaited, …

Total answers: 2

Django – gettext_lazy not working in string interpolation/concatenation (inside list)

Django – gettext_lazy not working in string interpolation/concatenation (inside list) Question: I have a dictionary of items with multiple properties. from django.utils.translation import ( gettext_lazy as _, ) {"item1": { "labels": [ _("label1"), "this is" + _("translatethis") + " label2", ] These items are then serialized in DRF. The problem is that _("label1") is being …

Total answers: 1

gettext: FileNotFoundError: [Errno 2] No translation file found for domain: 'base'

gettext: FileNotFoundError: [Errno 2] No translation file found for domain: 'base' Question: It seems that I am unable to get my GNU gettext utility to work properly, despite closely following both documentation and online resources. My folder structure is the following: / |- src | |- __init__.py | |- main.py |- locales |- ru |- …

Total answers: 1

sphinx gettext does not match textdomains in subdirectories when gettext_compact=False

sphinx gettext does not match textdomains in subdirectories when gettext_compact=False Question: I’m currently working on a complex documentation project with python sphinx. My next step is to enable internationalization. Project overview (simplified): doc build # contains sphinx build output images # contains image resources locales # gnu gettext structure (simplified) enLC_MESSAGESindex.po+mo enLC_MESSAGESarticlesconnect.po+mo deLC_MESSAGESindex.po+mo deLC_MESSAGESarticlesconnect.po+mo source …

Total answers: 2

How to use gettext with python >3.6 f-strings

How to use gettext with python >3.6 f-strings Question: Previously you would use gettext as following: _(‘Hey {},’).format(username) but what about new Python’s f-string? f’Hey {username}’ Asked By: mdargacz || Source Answers: ‘Hey {},’ is contained in your translation dictionary as is. If you use f’Hey {username},’, that creates another string, which won’t be translated. …

Total answers: 2

django-admin.py makemessages not working

django-admin.py makemessages not working Question: I am trying to translate a string. {% load i18n %} {% trans “Well, Hello there, how are you?” %} to… Hola amigo, ¿que tal? My settings.py file has this: LOCALE_PATHS = ( os.path.join(BASE_DIR, ‘translations’), ) And I am getting this: (env)glitch:translations nathann$ django-admin.py compilemessages CommandError: Can’t find msgfmt. Make …

Total answers: 11