mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
fix bug #6584
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36687 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ebd59dbc00
commit
53a72a4526
@ -22,6 +22,7 @@
|
||||
#include "support/debug.h"
|
||||
#include "support/FileName.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/Messages.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
@ -165,6 +166,10 @@ bool Language::read(Lexer & lex)
|
||||
encoding_ = encodings.fromLyXName("iso8859-1");
|
||||
LYXERR0("Unknown encoding " << encodingStr_);
|
||||
}
|
||||
// cache translation status. Calling getMessages() directly in
|
||||
// PrefLanguage::PrefLanguage() did only work if the gui language
|
||||
// was set to auto (otherwise all languages would be marked as available).
|
||||
translated_ = getMessages(code()).available();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Lexer;
|
||||
class Language {
|
||||
public:
|
||||
///
|
||||
Language() : rightToLeft_(false) {}
|
||||
Language() : rightToLeft_(false), translated_(false) {}
|
||||
/// LyX language name
|
||||
std::string const & lang() const { return lang_; }
|
||||
/// Babel language name
|
||||
@ -43,6 +43,8 @@ public:
|
||||
std::string const & display() const { return display_; }
|
||||
/// is this a RTL language?
|
||||
bool rightToLeft() const { return rightToLeft_; }
|
||||
/// Is an (at least partial) translation of this language available?
|
||||
bool translated() const { return translated_; }
|
||||
/// default encoding
|
||||
Encoding const * encoding() const { return encoding_; }
|
||||
///
|
||||
@ -98,6 +100,8 @@ private:
|
||||
bool internal_enc_;
|
||||
///
|
||||
bool as_babel_options_;
|
||||
///
|
||||
bool translated_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -2180,12 +2180,20 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
|
||||
defaultDecimalPointLE->setInputMask("X; ");
|
||||
defaultDecimalPointLE->setMaxLength(1);
|
||||
|
||||
// FIXME: This is wrong, we need filter this list based on the available
|
||||
// translation.
|
||||
set<string> added;
|
||||
uiLanguageCO->blockSignals(true);
|
||||
uiLanguageCO->addItem(qt_("Default"), toqstr("auto"));
|
||||
for (int i = 0; i != language_model->rowCount(); ++i) {
|
||||
QModelIndex index = language_model->index(i, 0);
|
||||
// Filter the list based on the available translation and add
|
||||
// each language code only once
|
||||
string const name = fromqstr(index.data(Qt::UserRole).toString());
|
||||
Language const * lang = languages.getLanguage(name);
|
||||
// never remove the currently selected language
|
||||
if (lang && name != form->rc().gui_language && name != lyxrc.gui_language)
|
||||
if (!lang->translated() || added.find(lang->code()) != added.end())
|
||||
continue;
|
||||
added.insert(lang->code());
|
||||
uiLanguageCO->addItem(index.data(Qt::DisplayRole).toString(),
|
||||
index.data(Qt::UserRole).toString());
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "support/debug.h"
|
||||
#include "support/docstring.h"
|
||||
#include "support/environment.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/Package.h"
|
||||
#include "support/unicode.h"
|
||||
|
||||
@ -121,6 +122,14 @@ void Messages::init()
|
||||
}
|
||||
|
||||
|
||||
bool Messages::available() const
|
||||
{
|
||||
string const test = languageTestString();
|
||||
string const trans = to_utf8(get(test));
|
||||
return !trans.empty() && trans != test;
|
||||
}
|
||||
|
||||
|
||||
docstring const Messages::get(string const & m) const
|
||||
{
|
||||
if (m.empty())
|
||||
|
@ -26,6 +26,8 @@ public:
|
||||
Messages(std::string const & l = std::string());
|
||||
///
|
||||
docstring const get(std::string const & msg) const;
|
||||
/// Is an (at least partial) translation of this language available?
|
||||
bool available() const;
|
||||
///
|
||||
static void init();
|
||||
///
|
||||
|
@ -268,7 +268,7 @@ FileName const i18nLibFileSearch(string const & dir, string const & name,
|
||||
each po file is able to tell us its name. (JMarc)
|
||||
*/
|
||||
|
||||
string lang = to_ascii(_("[[Replace with the code of your language]]"));
|
||||
string lang = to_ascii(_(languageTestString()));
|
||||
string const language = getEnv("LANGUAGE");
|
||||
if (!lang.empty() && !language.empty())
|
||||
lang = language;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "support/convert.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/qstring_helpers.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
@ -1283,6 +1284,12 @@ int findToken(char const * const str[], string const & search_token)
|
||||
}
|
||||
|
||||
|
||||
string const languageTestString()
|
||||
{
|
||||
return N_("[[Replace with the code of your language]]");
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, int arg1)
|
||||
{
|
||||
|
@ -283,6 +283,9 @@ docstring const getStringFromVector(std::vector<docstring> const & vec,
|
||||
/// found, else -1. The last item in \p str must be "".
|
||||
int findToken(char const * const str[], std::string const & search_token);
|
||||
|
||||
/// A test string that is supposed to be translated into the gettext code
|
||||
std::string const languageTestString();
|
||||
|
||||
template <class Arg1>
|
||||
docstring bformat(docstring const & fmt, Arg1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user