summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKarel Zak2017-04-25 17:05:09 +0200
committerKarel Zak2017-04-25 17:05:09 +0200
commit7095232d21232ca1ab307fbdd1a36471347f23c6 (patch)
tree3ad718b1bcd33acdebfecd955b0fdcc9824e19c3 /include
parentlsblk: don't duplicate columns (diff)
downloadkernel-qcow2-util-linux-7095232d21232ca1ab307fbdd1a36471347f23c6.tar.gz
kernel-qcow2-util-linux-7095232d21232ca1ab307fbdd1a36471347f23c6.tar.xz
kernel-qcow2-util-linux-7095232d21232ca1ab307fbdd1a36471347f23c6.zip
libfdisk: fix NLS support
The current libfdisk code uses gettext() to translate strings. It means it follows the default text domain (as set by textdomain(3) usually in the main program). This is useless for public shared library. We have call private bindtextdomain() and use dgettext() with private domain name to be independent on the main program. For this purpose include/nls.h supports UL_TEXTDOMAIN_EXPLICIT to use dgettext(). Note that libfdisk will continue to use util-linux.po, rather than keep the texts in the separate file. The nls.h has to be included only from fdiskP.h to be sure that nls.h works as expected for the library. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/nls.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/nls.h b/include/nls.h
index 3eabfe63b..50f4f29f7 100644
--- a/include/nls.h
+++ b/include/nls.h
@@ -20,9 +20,19 @@ struct lconv
# define localeconv() NULL
#endif
+
#ifdef ENABLE_NLS
# include <libintl.h>
-# define _(Text) gettext (Text)
+/*
+ * For NLS support in the public shared libraries we have to specify text
+ * domain name to be independend on the main program. For this purpose define
+ * UL_TEXTDOMAIN_EXPLICIT before you include nls.h to your shared library code.
+ */
+# ifdef UL_TEXTDOMAIN_EXPLICIT
+# define _(Text) dgettext (UL_TEXTDOMAIN_EXPLICIT, Text)
+# else
+# define _(Text) gettext (Text)
+# endif
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
@@ -37,7 +47,7 @@ struct lconv
# define _(Text) (Text)
# define N_(Text) (Text)
# define P_(Singular, Plural, n) ((n) == 1 ? (Singular) : (Plural))
-#endif
+#endif /* ENABLE_NLS */
#ifdef HAVE_LANGINFO_H
# include <langinfo.h>