refix i18n for --disable-nls

This commit is contained in:
Dana Jansens 2002-05-23 15:22:48 +00:00
parent e7c332a586
commit bbbe226ccc

View file

@ -46,7 +46,6 @@ extern "C" {
} }
#include <string> #include <string>
using std::string;
#include "i18n.h" #include "i18n.h"
@ -89,15 +88,11 @@ I18n::~I18n() {
#if defined(NLS) && defined(HAVE_CATOPEN) #if defined(NLS) && defined(HAVE_CATOPEN)
void I18n::openCatalog(const char *catalog) { void I18n::openCatalog(const char *catalog) {
int lp = strlen(LOCALEPATH), lc = strlen(locale), std::string catalog_filename = LOCALEPATH;
ct = strlen(catalog), len = lp + lc + ct + 3; catalog_filename += '/';
catalog_filename = new char[len]; catalog_filename += locale;
catalog_filename += '/';
strncpy(catalog_filename, LOCALEPATH, lp); catalog_filename += catalog;
*(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 # ifdef MCLoadBySet
catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet); catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet);
@ -108,22 +103,20 @@ void I18n::openCatalog(const char *catalog) {
if (catalog_fd == (nl_catd) -1) if (catalog_fd == (nl_catd) -1)
fprintf(stderr, "failed to open catalog, using default messages\n"); fprintf(stderr, "failed to open catalog, using default messages\n");
} }
#else // !HAVE_CATOPEN #else
void I18n::openCatalog(const char *) { void I18n::openCatalog(const char *) {
catalog_filename = (char *) 0;
} }
#endif // HAVE_CATOPEN #endif // HAVE_CATOPEN
#if defined(NLS) && defined(HAVE_CATGETS) #if defined(NLS) && defined(HAVE_CATGETS)
const char *I18n::getMessage(int set, int msg, const char *msgString) const { const char* I18n::operator()(int set, int msg, const char *msgString) const {
if (catalog_fd != (nl_catd) -1) if (catalog_fd != (nl_catd) -1)
return catgets(catalog_fd, set, msg, msgString); return catgets(catalog_fd, set, msg, msgString);
else else
return msgString; return msgString;
} }
#else #else
const char *I18n::getMessage(int, int, const char *msgString) const { const char* I18n::operator()(int, int, const char *msgString) const {
return msgString; return msgString;
} }
#endif #endif