summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2011-06-10 18:17:12 +0000
committerGreg Hudson <ghudson@mit.edu>2011-06-10 18:17:12 +0000
commitfd2f45cf93bfbf10863011fb1a61fc08041c2f51 (patch)
treedd1d90ae9e744d0c7e127ba17b08977c526d054f /src/include
parent71125ee37ecc540fb60a6efbf4dac80468e1359e (diff)
downloadkrb5-fd2f45cf93bfbf10863011fb1a61fc08041c2f51.tar.gz
krb5-fd2f45cf93bfbf10863011fb1a61fc08041c2f51.tar.xz
krb5-fd2f45cf93bfbf10863011fb1a61fc08041c2f51.zip
Add localization infrastructure
Adds build system logic, translation macros in k5-platform.h, and bindtextdomain calls in libkrb5 initialization. ticket: 6918 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24959 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/include')
-rw-r--r--src/include/k5-err.h4
-rw-r--r--src/include/k5-platform.h21
2 files changed, 18 insertions, 7 deletions
diff --git a/src/include/k5-err.h b/src/include/k5-err.h
index 483c5cd37..f9d5b0ce7 100644
--- a/src/include/k5-err.h
+++ b/src/include/k5-err.h
@@ -32,10 +32,6 @@
#ifndef K5_ERR_H
#define K5_ERR_H
-#ifndef _
-#define _(X) (X)
-#endif
-
#if defined(_MSDOS) || defined(_WIN32)
#include <win-mac.h>
#endif
diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h
index dd776e7ec..d8324839b 100644
--- a/src/include/k5-platform.h
+++ b/src/include/k5-platform.h
@@ -36,6 +36,7 @@
* + consistent getpwnam/getpwuid interfaces
* + va_copy fudged if not provided
* + [v]asprintf
+ * + _, N_, dgettext, bindtextdomain, setlocale (for localization)
*/
#ifndef K5_PLATFORM_H
@@ -1010,9 +1011,23 @@ extern int krb5int_mkstemp(char *);
extern void krb5int_zap(void *ptr, size_t len);
-/* Fudge for future adoption of gettext or the like. */
-#ifndef _
-#define _(X) (X)
+/*
+ * Localization macros. If we have gettext, define _ appropriately for
+ * translating a string. If we do not have gettext, define _, bindtextdomain,
+ * and setlocale as no-ops. N_ is always a no-op; it marks a string for
+ * extraction to pot files but does not translate it.
+ */
+#ifdef ENABLE_NLS
+#include <libintl.h>
+#include <locale.h>
+#define KRB5_TEXTDOMAIN "mit-krb5"
+#define _(s) dgettext(KRB5_TEXTDOMAIN, s)
+#else
+#define _(s) s
+#define dgettext(d, m) m
+#define bindtextdomain(p, d)
+#define setlocale(c, l)
#endif
+#define N_(s) s
#endif /* K5_PLATFORM_H */