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
|- LC_MESSAGES
|- base.mo
|- base.po
the top of my main.py reads like this (Windows machine):
import argparse
import gettext
from gettext import gettext as _
argparser = argparse.ArgumentParser()
argparser.add_argument("--language", required=False, default="en")
arguments = argparser.parse_args()
gettext.translation(
"base", localedir=r".\locales", languages=[arguments.language[:2]]
).install()
And yet, when I try to run the script in either English or Russian, I still get an error:
FileNotFoundError: [Errno 2] No translation file found for domain: 'base'
What am I doing wrong?
I’ve tried putting locales
dir inside the src
folder and dropping the dot prefix (gettext.translation("base", localedir=r"locales", ...
), but it doesn’t seem to have changed anything.