Update of /cvsroot/mahogany/M/src/gui
In directory usw-pr-cvs1:/tmp/cvs-serv5096/src/gui
Modified Files:
wxMApp.cpp
Log Message:
added --lang option and fixed i18n for Windows
Index: wxMApp.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMApp.cpp,v
retrieving revision 1.237
retrieving revision 1.238
diff -b -u -2 -r1.237 -r1.238
--- wxMApp.cpp 30 Apr 2002 09:51:44 -0000 1.237
+++ wxMApp.cpp 2 May 2002 22:42:42 -0000 1.238
@@ -770,31 +770,49 @@
#ifdef USE_I18N
// Set up locale first, so everything is in the right language.
- bool hasLocale = false;
-
+ wxString locale = m_cmdLineOptions->lang;
+ if ( locale.empty() )
+ {
+ // auto detect the language to use
+ //
+ // TODO: we can probably replace all this mess now with a call to
+ // wxLocale::Init(wxLANGUAGE_DEFAULT)?
#ifdef OS_UNIX
- const char *locale = getenv("LANG");
- hasLocale =
- locale &&
- (strcmp(locale, "C") != 0) &&
- (strcmp(locale, "en") != 0) &&
- (strncmp(locale,"en_", 3) != 0) &&
- (strcmp(locale, "us") != 0);
+ locale = getenv("LANG");
+ if ( !locale.empty() )
+ {
+ if ( (strcmp(locale, "C") == 0) ||
+ (strcmp(locale, "en") == 0) ||
+ (strncmp(locale,"en_", 3) == 0) ||
+ (strcmp(locale, "us") == 0) )
+ {
+ locale.clear();
+ }
+ }
+
+#ifdef __LINUX__
+ /* This is a hack for SuSE Linux which sets LANG="german" instead
+ of LANG="de". Once again, they do their own thing...
+ */
+ if ( wxStricmp(locale, "german") == 0 )
+ locale = "de_DE";
+#endif // __LINUX__
+
#elif defined(OS_WIN)
// this variable is not usually set under Windows, but give the user a
// chance to override our locale detection logic in case it doesn't work
// (which is well possible because it's totally untested)
- wxString locale = getenv("LANG");
- if ( locale.Length() > 0 )
+ locale = getenv("LANG");
+ if ( !locale.empty() )
{
// setting LANG to "C" disables all this
- hasLocale = (locale[0] != 'C') || (locale[1] != '\0');
+ if ( locale == "C" )
+ locale.clear();
}
- else
+ else // LANG not set
{
// try to detect locale ourselves
LCID lcid = GetThreadLocale(); // or GetUserDefaultLCID()?
WORD idLang = PRIMARYLANGID(LANGIDFROMLCID(lcid));
- hasLocale = idLang != LANG_ENGLISH;
- if ( hasLocale )
+ if ( idLang != LANG_ENGLISH )
{
static char s_countryName[256];
@@ -805,6 +823,4 @@
// this string is intentionally not translated
wxLogSysError("Can not get current locale setting.");
-
- hasLocale = FALSE;
}
else
@@ -818,12 +834,5 @@
# error "don't know how to get the current locale on this platform."
#endif // OS
-
-#ifdef __LINUX__
- /* This is a hack for SuSE Linux which sets LANG="german" instead
- of LANG="de". Once again, they do their own thing...
- */
- if( hasLocale && (wxStricmp(locale, "german") == 0) )
- locale = "de_DE";
-#endif // __LINUX__
+ }
// if we fail to load the msg catalog, remember it in this variable because
@@ -832,5 +841,5 @@
failedToSetLocale = false;
- if ( hasLocale )
+ if ( !locale.empty() )
{
// TODO should catch the error messages and save them for later
@@ -845,20 +854,26 @@
failedToSetLocale = true;
}
- else
+ else // set locale successfully
{
+ // now load the message catalogs
#ifdef OS_UNIX
String localePath;
localePath << M_BASEDIR << "/locale";
#elif defined(OS_WIN)
- // we can't use InitGlobalDir() here as the profile is not created yet,
- // but I don't have time to fix it right now - to do later!!
- #error "this code is broken and will crash" // FIXME
+ // the program directory is not initialized yet so we can't do much
+ // more than looking in the current directory...
+ wxString strPath;
+ ::GetModuleFileName(NULL, wxStringBuffer(strPath, MAX_PATH), MAX_PATH);
+
+ // get just the path
+ wxString strDir;
+ wxSplitPath(strPath, &strDir, NULL, NULL);
- InitGlobalDir();
String localePath;
- localePath << m_globalDir << "/locale";
+ localePath << strDir << "/locale";
#else
# error "don't know where to find message catalogs on this platform"
#endif // OS
+
m_Locale->AddCatalogLookupPathPrefix(localePath);
@@ -2026,4 +2041,5 @@
#define OPTION_DEBUGMAIL "debug"
#define OPTION_FOLDER "folder"
+#define OPTION_LANG "lang"
#define OPTION_NEWSGROUP "newsgroup"
#define OPTION_SAFE "safe"
@@ -2085,4 +2101,12 @@
},
+ // --lang option to specify the language to use
+ {
+ wxCMD_LINE_OPTION,
+ NULL,
+ OPTION_LANG,
+ gettext_noop("the language to use for the program messages"),
+ },
+
// --newsgroup to specify the newsgroup to post the message to
{
@@ -2180,4 +2204,6 @@
m_cmdLineOptions->useFolder = parser.Found(OPTION_FOLDER,
&m_cmdLineOptions->folder);
+
+ (void)parser.Found(OPTION_LANG, &m_cmdLineOptions->lang);
return true;
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates