mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
maint: improve i18n on non-Linux
Per the gettext developer: http://lists.gnu.org/archive/html/bug-gnu-utils/2010-10/msg00019.html http://lists.gnu.org/archive/html/bug-gnu-utils/2010-10/msg00021.html gettext() doesn't work correctly on all platforms unless you have called setlocale(). Furthermore, gnulib's gettext.h has provisions for setting up a default locale, which is the preferred method for libraries to use gettext without having to call textdomain() and override the main program's default domain (virInitialize already calls bindtextdomain(), but this is insufficient without the setlocale() added in this patch; and a redundant bindtextdomain() in this patch doesn't hurt, but serves as a good example for other packages that need to bind a second translation domain). This patch is needed to silence a new gnulib 'make syntax-check' rule in the next patch. * daemon/libvirtd.c (main): Setup locale and gettext. * src/lxc/lxc_controller.c (main): Likewise. * src/security/virt-aa-helper.c (main): Likewise. * src/storage/parthelper.c (main): Likewise. * tools/virsh.c (main): Fix exit status. * src/internal.h (DEFAULT_TEXT_DOMAIN): Define, for gettext.h. (_): Simplify definition accordingly. * po/POTFILES.in: Add src/storage/parthelper.c.
This commit is contained in:
@@ -1134,6 +1134,13 @@ main(int argc, char **argv)
|
||||
char profile[PATH_MAX];
|
||||
char include_file[PATH_MAX];
|
||||
|
||||
if (setlocale(LC_ALL, "") == NULL ||
|
||||
bindtextdomain(PACKAGE, LOCALEDIR) == NULL ||
|
||||
textdomain(PACKAGE) == NULL) {
|
||||
fprintf(stderr, _("%s: initialization failed\n"), argv0);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* clear the environment */
|
||||
environ = NULL;
|
||||
if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user