-
-
Notifications
You must be signed in to change notification settings - Fork 767
Support translation message contexts #1524
Description
Reported by jteh on 2011-05-26 00:47
There are necessarily a lot of short translatable strings in NVDA. However, some of these should be translated differently depending on the context. An example of this is the word "none", which is used for both symbol level and the eSpeak variant name.
Message contexts can be used to differentiate between these. In the code, we would write something like pgettext("symbol level", "none"). "symbol level" would then show up in the .po file in an msgctxt field. (See the Contexts section of the gettext manual for further details.)
Unfortunately, Python doesn't yet support this, and even when it does, it won't be in Python 2.x. However, it is fairly trivial for us to support fetching the right message in our code. The problem is that pygettext and msgfmt.py don't support this. There's a patch to update msgfmt.py, but I think we should just switch to the real gettext tools, as there are also other reasons to do this.
Notes:
- gettext 0.15 or later is required to do this. The only build of gettext 0.15 or later for Windows that I can find is at http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
- We need both http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip and http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-tools-dev_0.18.1.1-2_win32.zip . Extract both into the same directory.
- The context is just prepended to the msgid with a \x04 separator; e.g. "context\x04message". In languageHandler, we can define pgettext() to handle this and install it into the builtin namespace.
- scons needs to be updated to use these tools.
- Where do we tell the user to place them? We could say gettext in Program Files or we could install them somewhere in the NVDA build tree.
One major problem is that poedit doesn't support viewing contexts yet and many of our translators rely on poedit.