fix selection of locale when loading help files

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8519 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2004-03-24 12:05:57 +00:00
parent e942a15dd8
commit 54cdd0291a
2 changed files with 23 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2004-03-23 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* filetools.C (i18nLibFileSearch): fix the logic to match closely
what gettext does
2004-03-23 Angus Leeming <leeming@lyx.org> 2004-03-23 Angus Leeming <leeming@lyx.org>
* forkedcall.h (ForkedProcess, Forkedcall): change the signature of * forkedcall.h (ForkedProcess, Forkedcall): change the signature of

View File

@ -309,20 +309,32 @@ string const
i18nLibFileSearch(string const & dir, string const & name, i18nLibFileSearch(string const & dir, string const & name,
string const & ext) string const & ext)
{ {
// this comment is from intl/dcigettext.c. We try to mimick this // the following comments are from intl/dcigettext.c. We try
// behaviour here. // to mimick this behaviour here.
/* The highest priority value is the `LANGUAGE' environment /* The highest priority value is the `LANGUAGE' environment
variable. But we don't use the value if the currently variable. But we don't use the value if the currently
selected locale is the C locale. This is a GNU extension. */ selected locale is the C locale. This is a GNU extension. */
/* [Otherwise] We have to proceed with the POSIX methods of
looking to `LC_ALL', `LC_xxx', and `LANG'. On some systems
this can be done by the `setlocale' function itself. */
string const lc_all = GetEnv("LC_ALL"); #if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
string lang = GetEnv("LANGUAGE"); lang = setlocale(LC_MESSAGES, NULL);
if (lang.empty() || lc_all == "C") { #else
lang = lc_all; string lang = GetEnv("LC_ALL");
if (lang.empty()) {
lang = GetEnv("LC_MESSAGES");
if (lang.empty()) { if (lang.empty()) {
lang = GetEnv("LANG"); lang = GetEnv("LANG");
if (lang.empty())
lang = "C";
} }
} }
#endif
string const language = GetEnv("LANGUAGE");
if (lang != "C" && !language.empty())
lang = language;
lang = token(lang, '_', 0); lang = token(lang, '_', 0);