updated i18n sample, french translations are now in the "fr" subdirectory.

Added some documentation in readme.txt.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1399 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1999-01-13 19:01:43 +00:00
parent 2845ddc25c
commit fd323a5e23
11 changed files with 471 additions and 151 deletions

View File

@ -78,9 +78,18 @@ public:
// returns locale name
const char *GetLocale() const { return m_strLocale; }
// add a prefix to the catalog lookup path: the message catalog files will be
// looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix
// (in this order).
//
// This only applies to subsequent invocations of AddCatalog()!
static void AddCatalogLookupPathPrefix(const wxString& prefix);
// add a catalog: it's searched for in standard places (current directory
// first, system one after). It will be used for message lookup by
// GetString().
// first, system one after), but the you may prepend additional directories to
// the search path with AddCatalogLookupPathPrefix().
//
// The loaded catalog will be used for message lookup by GetString().
//
// Returns 'true' if it was successfully loaded
bool AddCatalog(const char *szDomain);

Binary file not shown.

View File

@ -0,0 +1,77 @@
# Message catalog file template for the wxWindows i18n sample
# Copyright (C) 1999 wxWindows development team
# Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
#
#: internat.cpp:146
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: wxWindows 2.0 i18n sample\n"
"POT-Creation-Date: 1999-01-13 18:19+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
#: internat.cpp:98
msgid "International wxWindows App"
msgstr "Application wxWindows internationale"
#: internat.cpp:105
msgid "&About..."
msgstr "&A propos..."
#: internat.cpp:107
msgid "E&xit"
msgstr "&Quitter"
#: internat.cpp:110
msgid "&Open bogus file"
msgstr "&Ouvrir un fichier"
#: internat.cpp:111
msgid "&Play a game"
msgstr "&Jouer"
#: internat.cpp:114
msgid "&File"
msgstr "&Fichier"
#: internat.cpp:115
msgid "&Test"
msgstr "&Test"
#: internat.cpp:138
msgid "I18n sample\n"
"© 1998, 1999 Vadim Zeitlin and Julian Smart"
msgstr "Exemple d'i18n\n"
"© 1998, 1999 Vadim Zeitlin et Julian Smart"
#: internat.cpp:139
msgid "About Internat"
msgstr "A propos d'Internat"
#: internat.cpp:144
msgid "Enter your number:"
msgstr "Entrez votre numéro:"
#: internat.cpp:145
msgid "Try to guess my number!"
msgstr "Essayez de déviner mon numéro!"
#: internat.cpp:150
msgid "You've probably entered an invalid number."
msgstr "Vous avez probablement entré un nombre invalide."
#: internat.cpp:154
msgid "Bad luck! try again..."
msgstr "Pas de chance! essayez encore..."
#: internat.cpp:158
msgid "Congratulations! you've won. Here is the magic phrase:"
msgstr "Félicitations! vouz avez gagné. Voilà la phrase magique:"
#: internat.cpp:162
msgid "Result"
msgstr "Resultat"

View File

@ -0,0 +1,131 @@
# Message catalog file template for the wxWindows i18n sample
# Copyright (C) 1999 wxWindows development team
# Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: wxWindows 2.0 i18n sample\n"
"POT-Creation-Date: 1999-01-13 18:19+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
#: file.cpp:182 hello.cpp:38
#, fuzzy, c-format
msgid "can't create file '%s'"
msgstr "impossible de créer le fichier '%s'"
#: file.cpp:213
#, c-format
msgid "can't open file '%s'"
msgstr "impossible d'ouvrir le fichier '%s'"
#: file.cpp:227
#, c-format
msgid "can't close file descriptor %d"
msgstr "impossible de fermer le descripteur %d"
#: file.cpp:244
#, c-format
msgid "can't read from file descriptor %d"
msgstr "impossible de lire à partir de descripteur %d"
#: file.cpp:258
#, c-format
msgid "can't write to file descriptor %d"
msgstr "impossible d'écrire sur le descripteur %d"
#: file.cpp:271
#, c-format
msgid "can't flush file descriptor %d"
msgstr "impossible de mettre à jour le descripteur %d"
#: file.cpp:308
#, c-format
msgid "can't seek on file descriptor %d"
msgstr "impossible de changer la position sur le descripteur %d"
#: file.cpp:322
#, c-format
msgid "can't get seek position on file descriptor %d"
msgstr "impossible d'obtenir la position courante sur le descripteur %d"
#: file.cpp:355
#, c-format
msgid "can't find length of file on file descriptor %d"
msgstr "impossible de trouver la taille du fichier ouvert sur le descripteur %d"
#: intl.cpp:139
#, c-format
msgid "catalog file for domain '%s' not found."
msgstr "impossible de trouver le catalogue de messages pour le domaine '%s'."
#: intl.cpp:177
#, c-format
msgid "'%s' is not a valid message catalog."
msgstr "'%s' n'est pas un catalogue de messages valid."
#: intl.cpp:330 intl.cpp:334
#, c-format
msgid "locale '%s' can not be set."
msgstr "impossible de passer à locale '%s'."
#: intl.cpp:431 intl.cpp:435
#, c-format
msgid "string '%s' not found in domain '%s' for locale '%s'."
msgstr "chaîne '%s' n'a pas été trouvée dans le domaine '%s' pour le locale '%s'."
#: intl.cpp:434 intl.cpp:438
#, c-format
msgid "string '%s' not found in locale '%s'."
msgstr "chaîne '%s' n'a pas été trouvée dans le locale '%s'."
#: log.cpp:104
#, c-format
msgid " (error %ld: %s)"
msgstr " (erreur %ld: %s)"
#: log.cpp:165
msgid "Debug: "
msgstr "Debug: "
#: log.cpp:171
msgid "Fatal error: "
msgstr "Erreur fatale: "
#: log.cpp:172
msgid "Program aborted.\n"
msgstr "Programme abandonné.\n"
#: log.cpp:177
msgid "Error: "
msgstr "Erreur: "
#: log.cpp:181
msgid "Warning: "
msgstr "Attention: "
#: log.cpp:268
#, c-format
msgid "Assert failed in file %s at line %d"
msgstr "Assertion est fausse dans le fichier %s à la ligne %d"
#: file.cpp:303
msgid "unknown seek origin"
msgstr ""
msgid "looking for catalog '%s' in path '%s'."
msgstr ""
#: intl.cpp:378
msgid "no message catalog list"
msgstr ""
msgid "OK"
msgstr "OK"
msgid "Cancel"
msgstr "Annuler"

View File

@ -54,7 +54,7 @@ public:
void OnAbout(wxCommandEvent& event);
void OnPlay(wxCommandEvent& event);
void OnOpen(wxCommandEvent& event);
bool OnClose(void) { return TRUE; }
bool OnClose() { return TRUE; }
DECLARE_EVENT_TABLE()
};
@ -80,11 +80,34 @@ IMPLEMENT_APP(MyApp)
// `Main program' equivalent, creating windows and returning main app frame
bool MyApp::OnInit(void)
bool MyApp::OnInit()
{
// Initialize the catalogs we'll be using
m_locale.Init("french", "fr", "C");
// set the language to use
const char *language = NULL;
const char *langid = NULL;
switch ( argc )
{
default:
// ignore the other args, fall through
case 3:
language = argv[1];
langid = argv[2];
break;
case 2:
language = argv[1];
break;
case 1:
language = "french";
langid = "fr";
};
// there are very few systems right now which support locales other than "C"
m_locale.Init(language, langid, "C");
// Initialize the catalogs we'll be using
/* not needed any more, done in wxLocale ctor
m_locale.AddCatalog("wxstd"); // 1) for library messages
*/
@ -95,14 +118,15 @@ bool MyApp::OnInit(void)
m_locale.AddCatalog("fileutils"); // 3) and another just for testing
// Create the main frame window
MyFrame *frame = new MyFrame((wxFrame *) NULL, _("International wxWindows App"), 50, 50, 150, 40);
MyFrame *frame = new MyFrame((wxFrame *) NULL, _("International wxWindows App"),
50, 50, 250, 40);
// Give it an icon
frame->SetIcon(wxICON(mondrian));
// Make a menubar
wxMenu *file_menu = new wxMenu;
file_menu->Append(MINIMAL_ABOUT, _("&About"));
file_menu->Append(MINIMAL_ABOUT, _("&About..."));
file_menu->AppendSeparator();
file_menu->Append(MINIMAL_QUIT, _("E&xit"));
@ -135,7 +159,8 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageDialog(this, _("I18n sample\n© Vadim Zeitlin & Julian Smart"),
wxMessageDialog(this, _("I18n sample\n"
"© 1998, 1999 Vadim Zeitlin and Julian Smart"),
_("About Internat"), wxOK | wxICON_INFORMATION).ShowModal();
}
@ -144,18 +169,21 @@ void MyFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
wxString str = wxGetTextFromUser(_("Enter your number:"),
_("Try to guess my number!"),
"", this);
if ( str.IsEmpty() )
return;
int num;
sscanf(str, "%d", &num);
if ( num == 0 )
str = _("you've probably entered an invalid number.");
str = _("You've probably entered an invalid number.");
else if ( num == 9 ) // this message is not translated (not in catalog)
str = _("you've found a bug in this program!");
str = "You've found a bug in this program!";
else if ( num != 17 ) // a more implicit way to write _()
str = wxGetTranslation("bad luck! try again...");
str = wxGetTranslation("Bad luck! try again...");
else {
str.Empty();
// string must be split in two -- otherwise the translation won't be found
str << _("congratulations! you've won. Here is the magic phrase:")
str << _("Congratulations! you've won. Here is the magic phrase:")
<< _("cannot create fifo `%s'");
}

Binary file not shown.

View File

@ -1,74 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: hello.cpp:44
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 1997-12-19 17:46+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
#: hello.cpp:31 hello.cpp:38
msgid "bad luck! try again..."
msgstr "pas de chance! essayez encore..."
#: hello.cpp:23 hello.cpp:24
#, c-format
msgid "usage: %s <number>"
msgstr "syntaxe: %s <nombre>"
#: hello.cpp:29 hello.cpp:34
msgid "you've probably entered an invalid number."
msgstr "vous avez du entrer un nombre invalide."
#: hello.cpp:33 hello.cpp:40
msgid "congratulations! you've won. Here is the magic phrase:"
msgstr "felicitations! vous avez gagne. Voici la phrase magique:"
#: hello.cpp:17
msgid "wxstd"
msgstr ""
#: hello.cpp:18
msgid "hello"
msgstr ""
#: hello.cpp:19
msgid "fileutils"
msgstr ""
#: hello.cpp:20
msgid "french"
msgstr ""
#: hello.cpp:20
msgid "fr"
msgstr ""
#: hello.cpp:20
msgid "C"
msgstr ""
#: hello.cpp:27
msgid "nosuchfi.le"
msgstr ""
#: hello.cpp:36
msgid "You've found a bug in this program!"
msgstr ""
#: hello.cpp:43
#, c-format
msgid "cannot create fifo `%s'"
msgstr ""
#: hello.cpp:43
msgid "foo"
msgstr ""

View File

@ -0,0 +1,82 @@
This is the README file for the internationalization sample for wxWindows 2.0.
Q. What does this stupid program do?
A. It demonstrates how to translate all program messages to a foreign language.
In any program using wxWindows there is going to be 3 kinds of messages: the
messages from the program itself, the messages from the wxWindows library and
the messages from the system (e.g. system error messages). This program
translates the first 2 kinds of messages but the system messages will be only
translated if your system supports it.
Brief usage summary: "Test|File" tries to open a non existing file (provoking
system error message), "Test|Play" shows a message box asking for a number.
Hint: try some special values like 9 and 17.
Q. Why the error message when I try to open a non existing file is only partly
translated?
A. Your system doesn't have the translation in the language you use, sorry.
Q. Why the message when I enter '9' is not translated?
A. This is on purpose: the corresponding string wasn't enclosed in _() macro and
so didn't get into the message catalog when it was created using xgettext.
Q. Why the message when I enter '17' is only partly translated?
A. This will only work under some versions of Linux, don't worry if the second
half of the sentence is not translated.
Q. I don't speak french, what about translations to <language>?
A. Please write them - see the next question. French is chosen by default
because it's the only translation which is currently available. To test
translations to the other languages please run the sample with 2 command line
arguments: the full language name and the name of the directory where the
message catalogs for this language are (will be taken as 2 first letters of
the language name if only 1 argument is given).
Q. How to do translations to other language?
A. First of all, you will need the GNU gettext tools (see the next question).
After you've probably installed them, type the following (example is for Unix
and you should do exactly the same under Windows).
# all translations forgiven language should be in a separate directory.
# Please use the standard abbreviation for the language names!
mkdir <language>
cd <language>
# generate the .po file for the program itself
# see `xgettext --help' for options, "-C" is important!
xgettext -C -o internat.po ../internat.cpp
# .po file for wxWindows might be generated in the same way, but for now just
# take this one...
cp ../wxstd.po .
# now edit the files and do translate strings (this isn't done by gettext)
# you can use another editor if you wish :-)
vi internat.po wxstd.po
# create the message catalog files
msgfmt -o internat.mo internat.po
msgfmt -o wxstd.mo wxstd.po
# run the sample to test it
cd ..
./$OSTYPE/internat <language> <langid>
Q. How to get the gettext tools?
A. For Unix, you should be able to get the source distribution of any GNU mirror
(see www.gnu.org for a start). gettext() version 0.10 is buggy, try to get at
least version strictly greater than 0.10. gettext RPMs can be downloaded from
the standard locations for Linux. For Windows, you can get the precompiled
binaries from wxWindows web page.
Q. What's i18n?
A. Count the number of letters in the word "internationalization".
Q. Where to send comments,
additional translations,
flames,
money?
A. To Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>,
wxWindows list <wxwin-developers@wx.dent.med.uni-muenchen.de>,
/dev/null (platform-dependent),
wxWindows dev team Suiss banc account.

View File

@ -21,103 +21,102 @@ msgstr ""
#: file.cpp:182 hello.cpp:38
#, fuzzy, c-format
msgid "can't create file '%s'"
msgstr "impossible de créer le fichier '%s'"
msgstr ""
#: file.cpp:213
#, c-format
msgid "can't open file '%s'"
msgstr "impossible d'ouvrir le fichier '%s'"
msgstr ""
#: file.cpp:227
#, c-format
msgid "can't close file descriptor %d"
msgstr "impossible de fermer le descripteur %d"
msgstr ""
#: file.cpp:244
#, c-format
msgid "can't read from file descriptor %d"
msgstr "impossible de lire à partir de descripteur %d"
msgstr ""
#: file.cpp:258
#, c-format
msgid "can't write to file descriptor %d"
msgstr "impossible d'écrire sur le descripteur %d"
msgstr ""
#: file.cpp:271
#, c-format
msgid "can't flush file descriptor %d"
msgstr "impossible de mettre à jour le descripteur %d"
msgstr ""
#: file.cpp:308
#, c-format
msgid "can't seek on file descriptor %d"
msgstr "impossible de changer la position sur le descripteur %d"
msgstr ""
#: file.cpp:322
#, c-format
msgid "can't get seek position on file descriptor %d"
msgstr "impossible d'obtenir la position courante sur le descripteur %d"
msgstr ""
#: file.cpp:355
#, c-format
msgid "can't find length of file on file descriptor %d"
msgstr ""
"impossible de trouver la taille du fichier ouvert sur le descripteur %d"
#: intl.cpp:139
#, c-format
msgid "catalog file for domain '%s' not found."
msgstr "impossible de trouver le catalogue de messages pour le domaine '%s'."
msgstr ""
#: intl.cpp:177
#, c-format
msgid "'%s' is not a valid message catalog."
msgstr "'%s' n'est pas un catalogue de messages valid."
msgstr ""
#: intl.cpp:330 intl.cpp:334
#, c-format
msgid "locale '%s' can not be set."
msgstr "impossible de passer à locale '%s'."
msgstr ""
#: intl.cpp:431 intl.cpp:435
#, c-format
msgid "string '%s' not found in domain '%s' for locale '%s'."
msgstr "chaîne '%s' n'a pas été trouvé dans le domaine '%s' pour le locale '%s'."
msgstr ""
#: intl.cpp:434 intl.cpp:438
#, c-format
msgid "string '%s' not found in locale '%s'."
msgstr "chaîne '%s' n'a pas été trouvé dans le locale '%s'."
msgstr ""
#: log.cpp:104
#, c-format
msgid " (error %ld: %s)"
msgstr " (erreur %ld: %s)"
msgstr ""
#: log.cpp:165
msgid "Debug: "
msgstr "Debug: "
msgstr ""
#: log.cpp:171
msgid "Fatal error: "
msgstr "Erreur fatale: "
msgstr ""
#: log.cpp:172
msgid "Program aborted.\n"
msgstr "Programme abandonné.\n"
msgstr ""
#: log.cpp:177
msgid "Error: "
msgstr "Erreur: "
msgstr ""
#: log.cpp:181
msgid "Warning: "
msgstr "Attention: "
msgstr ""
#: log.cpp:268
#, c-format
msgid "Assert failed in file %s at line %d"
msgstr "Assertion est fausse dans le fichier %s à la ligne %d"
msgstr ""
#: file.cpp:303
msgid "unknown seek origin"
@ -129,3 +128,9 @@ msgstr ""
#: intl.cpp:378
msgid "no message catalog list"
msgstr ""
msgid "OK"
msgstr ""
msgid "Cancel"
msgstr ""

View File

@ -148,6 +148,13 @@ private:
char *m_pszName; // name of the domain
};
// ----------------------------------------------------------------------------
// global variables
// ----------------------------------------------------------------------------
// the list of the directories to search for message catalog files
static wxArrayString s_searchPrefixes;
// ============================================================================
// implementation
// ============================================================================
@ -197,42 +204,77 @@ wxMsgCatalog::~wxMsgCatalog()
wxDELETEA(m_pszName);
}
// small class to suppress the translation erros until exit from current scope
class NoTransErr
{
public:
public:
NoTransErr() { wxSuppressTransErrors(); }
~NoTransErr() { wxRestoreTransErrors(); }
};
// return all directories to search for given prefix
static wxString GetAllMsgCatalogSubdirs(const char *prefix,
const char *lang)
{
wxString searchPath;
// search first in prefix/fr/LC_MESSAGES, then in prefix/fr and finally in
// prefix (assuming the language is 'fr')
searchPath << prefix << FILE_SEP_PATH << lang << FILE_SEP_PATH
<< "LC_MESSAGES" << PATH_SEP
<< prefix << FILE_SEP_PATH << lang << PATH_SEP
<< prefix << PATH_SEP;
return searchPath;
}
// construct the search path for the given language
static wxString GetFullSearchPath(const char *lang)
{
wxString searchPath;
// first take the entries explicitly added by the program
size_t count = s_searchPrefixes.Count();
for ( size_t n = 0; n < count; n++ )
{
searchPath << GetAllMsgCatalogSubdirs(s_searchPrefixes[n], lang)
<< PATH_SEP;
}
// then take the current directory
// FIXME it should be the directory of the executable
searchPath << GetAllMsgCatalogSubdirs(".", lang) << PATH_SEP;
// and finally add some standard ones
searchPath
<< GetAllMsgCatalogSubdirs("/usr/share/locale", lang) << PATH_SEP
<< GetAllMsgCatalogSubdirs("/usr/lib/locale", lang) << PATH_SEP
<< GetAllMsgCatalogSubdirs("/usr/local/share/locale", lang);
return searchPath;
}
// open disk file and read in it's contents
bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName)
{
// search order (assume language 'foo') is
// 1) $LC_PATH/foo/LC_MESSAGES (if LC_PATH set)
// 2) ./foo/LC_MESSAGES
// 3) ./foo
// 4) . (Added by JACS)
//
// under UNIX we search also in:
// 5) /usr/share/locale/foo/LC_MESSAGES (Linux)
// 6) /usr/lib/locale/foo/LC_MESSAGES (Solaris)
#define MSG_PATH FILE_SEP_PATH + "LC_MESSAGES" PATH_SEP
wxString strPath("");
// FIXME VZ: I forgot the exact meaning of LC_PATH - anyone to remind me?
#if 0
const char *pszLcPath = getenv("LC_PATH");
if ( pszLcPath != NULL )
strPath += pszLcPath + wxString(szDirPrefix) + MSG_PATH; // (1)
strPath += pszLcPath + wxString(szDirPrefix) + MSG_PATH;
#endif // 0
// NB: '<<' is unneeded between too literal strings:
// they are concatenated at compile time
strPath += "./" + wxString(szDirPrefix) + MSG_PATH // (2)
+ "./" + szDirPrefix + FILE_SEP_PATH + PATH_SEP // (3)
+ "." + PATH_SEP
#ifdef __UNIX__
"/usr/share/locale/" + szDirPrefix + MSG_PATH // (5)
"/usr/lib/locale/" + szDirPrefix + MSG_PATH // (6)
#endif //UNIX
;
wxString searchPath = GetFullSearchPath(szDirPrefix);
const char *sublocale = strchr(szDirPrefix, '_');
if ( sublocale )
{
// also add just base locale name: for things like "fr_BE" (belgium
// french) we should use "fr" if no belgium specific message catalogs
// exist
searchPath << GetFullSearchPath(wxString(szDirPrefix).
Left((size_t)(sublocale - szDirPrefix)))
<< PATH_SEP;
}
wxString strFile = szName;
strFile += MSGCATALOG_EXTENSION;
@ -244,10 +286,10 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName)
NoTransErr noTransErr;
wxLogVerbose(_("looking for catalog '%s' in path '%s'."),
szName, strPath.c_str());
szName, searchPath.c_str());
wxString strFullName;
if ( !wxFindFileInPath(&strFullName, strPath, strFile) ) {
if ( !wxFindFileInPath(&strFullName, searchPath, strFile) ) {
wxLogWarning(_("catalog file for domain '%s' not found."), szName);
return FALSE;
}
@ -384,8 +426,8 @@ bool wxLocale::Init(const char *szName,
// the short name will be used to look for catalog files as well,
// so we need something here
if ( m_strShort.IsEmpty() ) {
// #### I don't know how these 2 letter abbreviations are formed,
// this wild guess is almost surely wrong
// FIXME I don't know how these 2 letter abbreviations are formed,
// this wild guess is surely wrong
m_strShort = wxToLower(szLocale[0]) + wxToLower(szLocale[1]);
}
@ -401,20 +443,29 @@ bool wxLocale::Init(const char *szName,
return bOk;
}
void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
{
if ( s_searchPrefixes.Index(prefix) == NOT_FOUND )
{
s_searchPrefixes.Add(prefix);
}
//else: already have it
}
// clean up
wxLocale::~wxLocale()
{
// free memory
wxMsgCatalog *pTmpCat;
while ( m_pMsgCat != NULL ) {
pTmpCat = m_pMsgCat;
m_pMsgCat = m_pMsgCat->m_pNext;
delete pTmpCat;
}
// restore old locale
wxSetLocale(m_pOldLocale);
setlocale(LC_ALL, m_pszOldLocale);
// free memory
wxMsgCatalog *pTmpCat;
while ( m_pMsgCat != NULL ) {
pTmpCat = m_pMsgCat;
m_pMsgCat = m_pMsgCat->m_pNext;
delete pTmpCat;
}
// restore old locale
wxSetLocale(m_pOldLocale);
setlocale(LC_ALL, m_pszOldLocale);
}
// get the translation of given string in current locale
@ -444,16 +495,27 @@ const char *wxLocale::GetString(const char *szOrigString,
if ( pszTrans == NULL ) {
if ( wxIsLoggingTransErrors() ) {
// suppress further error messages
// (do it before LogWarning to prevent infinite recursion!)
// suppress further error messages if we're not debugging: this avoids
// flooding the user with messages about each and every missing string if,
// for example, a whole catalog file is missing.
// do it before calling LogWarning to prevent infinite recursion!
#ifdef __WXDEBUG__
NoTransErr noTransErr;
#else // !debug
wxSuppressTransErrors();
#endif // debug/!debug
if ( szDomain != NULL )
{
wxLogWarning(_("string '%s' not found in domain '%s' for locale '%s'."),
szOrigString, szDomain, m_strLocale.c_str());
szOrigString, szDomain, m_strLocale.c_str());
}
else
{
wxLogWarning(_("string '%s' not found in locale '%s'."),
szOrigString, m_strLocale.c_str());
szOrigString, m_strLocale.c_str());
}
}
return szOrigString;