aboutsummaryrefslogtreecommitdiff
path: root/src/i18n.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2002-12-01 13:42:15 (GMT)
committerrathnor <rathnor>2002-12-01 13:42:15 (GMT)
commit28b5c604490094e187494dcc566bd3d7a05a2c25 (patch)
tree8f78f5714a5cd055c10b067a2656fe7b2338e71a /src/i18n.cc
parentb9134162f9633784d9097df18769a699a62650fe (diff)
downloadfluxbox_pavel-28b5c604490094e187494dcc566bd3d7a05a2c25.zip
fluxbox_pavel-28b5c604490094e187494dcc566bd3d7a05a2c25.tar.bz2
Indenting from tabs to emacs 4-space
Diffstat (limited to 'src/i18n.cc')
-rw-r--r--src/i18n.cc78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/i18n.cc b/src/i18n.cc
index 7fb0cc2..44bc7d0 100644
--- a/src/i18n.cc
+++ b/src/i18n.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: i18n.cc,v 1.6 2002/08/13 23:54:41 fluxgen Exp $ 25// $Id: i18n.cc,v 1.7 2002/12/01 13:42:07 rathnor Exp $
26 26
27//usr GNU extensions 27//usr GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -53,36 +53,36 @@ using std::endl;
53using std::string; 53using std::string;
54 54
55void NLSInit(const char *catalog) { 55void NLSInit(const char *catalog) {
56 I18n *i18n = I18n::instance(); 56 I18n *i18n = I18n::instance();
57 i18n->openCatalog(catalog); 57 i18n->openCatalog(catalog);
58} 58}
59 59
60 60
61I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) { 61I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) {
62#ifdef HAVE_SETLOCALE 62#ifdef HAVE_SETLOCALE
63 //make sure we don't get 0 to m_locale string 63 //make sure we don't get 0 to m_locale string
64 char *temp = setlocale(LC_ALL, ""); 64 char *temp = setlocale(LC_ALL, "");
65 m_locale = ( temp ? temp : ""); 65 m_locale = ( temp ? temp : "");
66 if (m_locale.size() == 0) { 66 if (m_locale.size() == 0) {
67 cerr<<"Warning: Failed to set locale, reverting to \"C\""<<endl; 67 cerr<<"Warning: Failed to set locale, reverting to \"C\""<<endl;
68#endif // HAVE_SETLOCALE 68#endif // HAVE_SETLOCALE
69 m_locale = "C"; 69 m_locale = "C";
70#ifdef HAVE_SETLOCALE 70#ifdef HAVE_SETLOCALE
71 } else { 71 } else {
72 // MB_CUR_MAX returns the size of a char in the current locale 72 // MB_CUR_MAX returns the size of a char in the current locale
73 if (MB_CUR_MAX > 1) 73 if (MB_CUR_MAX > 1)
74 m_multibyte = true; 74 m_multibyte = true;
75 75
76 // truncate any encoding off the end of the locale 76 // truncate any encoding off the end of the locale
77 77
78 string::size_type index = m_locale.find('@'); 78 string::size_type index = m_locale.find('@');
79 if (index != string::npos) 79 if (index != string::npos)
80 m_locale.erase(index); //erase all characters starting at index 80 m_locale.erase(index); //erase all characters starting at index
81 81
82 index = m_locale.find('.'); 82 index = m_locale.find('.');
83 if (index != string::npos) 83 if (index != string::npos)
84 m_locale.erase(index); //erase all characters starting at index 84 m_locale.erase(index); //erase all characters starting at index
85 } 85 }
86#endif // HAVE_SETLOCALE 86#endif // HAVE_SETLOCALE
87} 87}
88 88
@@ -90,37 +90,37 @@ I18n::I18n():m_multibyte(false), m_catalog_fd((nl_catd)(-1)) {
90I18n::~I18n() { 90I18n::~I18n() {
91 91
92#if defined(NLS) && defined(HAVE_CATCLOSE) 92#if defined(NLS) && defined(HAVE_CATCLOSE)
93 if (m_catalog_fd != (nl_catd)-1) 93 if (m_catalog_fd != (nl_catd)-1)
94 catclose(m_catalog_fd); 94 catclose(m_catalog_fd);
95#endif // HAVE_CATCLOSE 95#endif // HAVE_CATCLOSE
96} 96}
97 97
98I18n *I18n::instance() { 98I18n *I18n::instance() {
99 static I18n singleton; //singleton object 99 static I18n singleton; //singleton object
100 return &singleton; 100 return &singleton;
101} 101}
102 102
103void I18n::openCatalog(const char *catalog) { 103void I18n::openCatalog(const char *catalog) {
104#if defined(NLS) && defined(HAVE_CATOPEN) 104#if defined(NLS) && defined(HAVE_CATOPEN)
105 105
106 string catalog_filename = LOCALEPATH; 106 string catalog_filename = LOCALEPATH;
107 catalog_filename += '/'; 107 catalog_filename += '/';
108 catalog_filename += m_locale; 108 catalog_filename += m_locale;
109 catalog_filename += '/'; 109 catalog_filename += '/';
110 catalog_filename += catalog; 110 catalog_filename += catalog;
111 111
112#ifdef MCLoadBySet 112#ifdef MCLoadBySet
113 m_catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet); 113 m_catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet);
114#else // !MCLoadBySet 114#else // !MCLoadBySet
115 m_catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE); 115 m_catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE);
116#endif // MCLoadBySet 116#endif // MCLoadBySet
117 117
118 if (m_catalog_fd == (nl_catd)-1) 118 if (m_catalog_fd == (nl_catd)-1)
119 cerr<<"Warning: Failed to open catalog, using default messages."<<endl; 119 cerr<<"Warning: Failed to open catalog, using default messages."<<endl;
120 120
121#else // !HAVE_CATOPEN 121#else // !HAVE_CATOPEN
122 122
123 m_catalog_fd = (nl_catd)-1; 123 m_catalog_fd = (nl_catd)-1;
124#endif // HAVE_CATOPEN 124#endif // HAVE_CATOPEN
125} 125}
126 126
@@ -128,9 +128,9 @@ void I18n::openCatalog(const char *catalog) {
128const char *I18n::getMessage(int set_number, int message_number, const char *default_message) { 128const char *I18n::getMessage(int set_number, int message_number, const char *default_message) {
129 129
130#if defined(NLS) && defined(HAVE_CATGETS) 130#if defined(NLS) && defined(HAVE_CATGETS)
131 if (m_catalog_fd != (nl_catd)-1) 131 if (m_catalog_fd != (nl_catd)-1)
132 return (const char *) catgets(m_catalog_fd, set_number, message_number, default_message); 132 return (const char *) catgets(m_catalog_fd, set_number, message_number, default_message);
133 else 133 else
134#endif // NLS && HAVE_CATGETS 134#endif // NLS && HAVE_CATGETS
135 return default_message; 135 return default_message;
136} 136}