X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FMessages.cpp;h=5eee6b7f6d5aa20d29b6d255c6b3adb208ce8cd3;hb=f1ab5dfc5878bc736fd185279a0ef7a185b2d8d8;hp=cf9bf7bb6d4fede05523148e067deb03e4838818;hpb=16fd47ad8f5d78a3b7266520b0868c1e2bd0dcac;p=lyx.git diff --git a/src/support/Messages.cpp b/src/support/Messages.cpp index cf9bf7bb6d..5eee6b7f6d 100644 --- a/src/support/Messages.cpp +++ b/src/support/Messages.cpp @@ -33,7 +33,7 @@ void cleanTranslation(docstring & trans) /* Some english words have different translations, depending on context. In these cases the original string is augmented by - context information (e.g. "To:[[[as in 'From page x to page + context information (e.g. "To:[[as in 'From page x to page y']]" and "To:[[as in 'From format x to format y']]". This means that we need to filter out everything in double square brackets at the end of the string, otherwise the user sees @@ -112,9 +112,22 @@ string Messages::language() const } -bool Messages::available() const +bool Messages::available(string const & c) { - return !language().empty(); + static string locale_dir = package().locale_dir().toFilesystemEncoding(); + string code = c; + // this loops at most twice + while (true) { + string const filen = locale_dir + "/" + code + + "/LC_MESSAGES/"PACKAGE".mo"; + if (FileName(filen).isReadableFile()) + return true; + if (contains(code, '_')) + code = token(code, '_', 0); + else return false; + } + return false; + } @@ -221,9 +234,14 @@ docstring const Messages::get(string const & m) const return trans; } +std::string Messages::language() const + { + return string(); + } -bool Messages::available() const +bool Messages::available(string const & c) { + (void)c; return false; }