summaryrefslogtreecommitdiff
path: root/src/FbTk/I18n.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/I18n.cc')
-rw-r--r--src/FbTk/I18n.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/FbTk/I18n.cc b/src/FbTk/I18n.cc
index c41f98c..62fda06 100644
--- a/src/FbTk/I18n.cc
+++ b/src/FbTk/I18n.cc
@@ -75,7 +75,7 @@ I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) {
75#ifdef HAVE_SETLOCALE 75#ifdef HAVE_SETLOCALE
76 //make sure we don't get 0 to m_locale string 76 //make sure we don't get 0 to m_locale string
77 char *temp = setlocale(LC_MESSAGES, ""); 77 char *temp = setlocale(LC_MESSAGES, "");
78 m_locale = ( temp ? temp : ""); 78 m_locale = ( temp ? temp : "");
79 if (m_locale.empty()) { 79 if (m_locale.empty()) {
80 cerr<<"Warning: Failed to set locale, reverting to \"C\""<<endl; 80 cerr<<"Warning: Failed to set locale, reverting to \"C\""<<endl;
81#endif // HAVE_SETLOCALE 81#endif // HAVE_SETLOCALE
@@ -90,9 +90,9 @@ I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) {
90 // MB_CUR_MAX returns the size of a char in the current locale 90 // MB_CUR_MAX returns the size of a char in the current locale
91 if (MB_CUR_MAX > 1) 91 if (MB_CUR_MAX > 1)
92 m_multibyte = true; 92 m_multibyte = true;
93 93
94 // truncate any encoding off the end of the locale 94 // truncate any encoding off the end of the locale
95 95
96 // remove everything after @ 96 // remove everything after @
97 string::size_type index = m_locale.find('@'); 97 string::size_type index = m_locale.find('@');
98 if (index != string::npos) 98 if (index != string::npos)
@@ -150,12 +150,17 @@ void I18n::openCatalog(const char *catalog) {
150} 150}
151 151
152 152
153const char *I18n::getMessage(int set_number, int message_number, 153FbString I18n::getMessage(int set_number, int message_number,
154 const char *default_message) const { 154 const char *default_message) const {
155 155
156#if defined(NLS) && defined(HAVE_CATGETS) 156#if defined(NLS) && defined(HAVE_CATGETS)
157 if (m_catalog_fd != (nl_catd)-1) 157 if (m_catalog_fd != (nl_catd)-1) {
158 return (const char *) catgets(m_catalog_fd, set_number, message_number, default_message); 158 const char *ret = catgets(m_catalog_fd, set_number, message_number, default_message);
159 if (ret == default_message || ret == NULL)
160 return default_message; // don't recode the default
161
162 return FbStringUtil::LocaleStrToFb(ret);
163 }
159 else 164 else
160#endif // NLS && HAVE_CATGETS 165#endif // NLS && HAVE_CATGETS
161 return default_message; 166 return default_message;