summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-05-23 15:11:41 +0000
committerDana Jansens <danakj@orodu.net>2002-05-23 15:11:41 +0000
commitac62af410dd5ea8ade914f47c9d5d269de16d59a (patch)
treef300a1de25b53462e328dc123cd05e0454fbcae7
parentd03852ad25b4d43e1420d9aced516507fa572800 (diff)
fix compiling with --disable-nls
-rw-r--r--src/i18n.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/i18n.cc b/src/i18n.cc
index b8aa361a..b31dd5a3 100644
--- a/src/i18n.cc
+++ b/src/i18n.cc
@@ -87,13 +87,17 @@ I18n::~I18n() {
}
-void I18n::openCatalog(const char *catalog) {
#if defined(NLS) && defined(HAVE_CATOPEN)
- string catalog_filename = LOCALEPATH;
- catalog_filename += '/';
- catalog_filename += locale;
- catalog_filename += '/';
- catalog_filename += catalog;
+void I18n::openCatalog(const char *catalog) {
+ int lp = strlen(LOCALEPATH), lc = strlen(locale),
+ ct = strlen(catalog), len = lp + lc + ct + 3;
+ catalog_filename = new char[len];
+
+ strncpy(catalog_filename, LOCALEPATH, lp);
+ *(catalog_filename + lp) = '/';
+ strncpy(catalog_filename + lp + 1, locale, lc);
+ *(catalog_filename + lp + lc + 1) = '/';
+ strncpy(catalog_filename + lp + lc + 2, catalog, ct + 1);
# ifdef MCLoadBySet
catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet);
@@ -103,14 +107,23 @@ void I18n::openCatalog(const char *catalog) {
if (catalog_fd == (nl_catd) -1)
fprintf(stderr, "failed to open catalog, using default messages\n");
-#endif // HAVE_CATOPEN
}
+#else // !HAVE_CATOPEN
+void I18n::openCatalog(const char *) {
+ catalog_filename = (char *) 0;
+}
+#endif // HAVE_CATOPEN
+
-const char* I18n::operator()(int set, int msg, const char *msgString) const {
#if defined(NLS) && defined(HAVE_CATGETS)
+const char *I18n::getMessage(int set, int msg, const char *msgString) const {
if (catalog_fd != (nl_catd) -1)
return catgets(catalog_fd, set, msg, msgString);
else
-#endif
return msgString;
}
+#else
+const char *I18n::getMessage(int, int, const char *msgString) const {
+ return msgString;
+}
+#endif