Skip to content

scangobj: reset locale environment variables before running

GNU gettext runtime doesn't always honor the locale controlled by libc. On non-glibc platforms, if per-thread locale isn't set, it may try to read environment variables by itself in order to figure out the locale. Therefore, even if setlocale is never called, gettext may still decide to translate text based on environment variables, causing the content of the documentation to be irreproducible because it depends on the environment on the build machine. Furthermore, since setlocale isn't called, LC_CTYPE defaults to C and non-ASCII characters coming from translations get converted to question marks. The result is that the documentation for GObject properties without gtk-doc comments becomes unreadable because blurbs of properties are translated in a broken way.

To avoid gettext from doing unnecessary translation during building the documentation, we should set LC_MESSAGES environment variable to C before running the main program. LC_ALL is unset because it overrides LC_MESSAGES. Doing so should be harmless because the program already operates in C locale on systems using glibc.

This is GtkTreeView documentation generated on FreeBSD using zh_TW.UTF-8 locale
2019-07-05_00-32-27_的螢幕擷圖

Merge request reports