]> git.lyx.org Git - lyx.git/blobdiff - src/support/Messages.cpp
remove unnecessary Carbon include
[lyx.git] / src / support / Messages.cpp
index cf9bf7bb6d4fede05523148e067deb03e4838818..5eee6b7f6d5aa20d29b6d255c6b3adb208ce8cd3 100644 (file)
@@ -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;
 }