[keyboard] Re-jig translation extraction
- Use classes to prompt lupdate to extract with a better context (e.g. the class name, rather than plain "QObject") so that the translation-lookup can use the named context. - Add hard-coded "default" variant - Add totally bogus Tajik translations, for testing purposes
This commit is contained in:
parent
1a5fa36fb6
commit
f088efdf84
3556
lang/kb_en.ts
3556
lang/kb_en.ts
File diff suppressed because it is too large
Load Diff
3562
lang/kb_tg.ts
3562
lang/kb_tg.ts
File diff suppressed because it is too large
Load Diff
@ -564,4 +564,5 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
void
|
||||
Config::retranslate()
|
||||
{
|
||||
retranslateKeyboardModels();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,6 +20,18 @@
|
||||
|
||||
static QTranslator* s_kbtranslator = nullptr;
|
||||
|
||||
void
|
||||
retranslateKeyboardModels()
|
||||
{
|
||||
cqDeleter< QTranslator > d{ s_kbtranslator };
|
||||
if ( !s_kbtranslator )
|
||||
{
|
||||
s_kbtranslator = new QTranslator;
|
||||
}
|
||||
d.preserve = CalamaresUtils::loadTranslator( QLocale(), QStringLiteral("kb_"), s_kbtranslator );
|
||||
}
|
||||
|
||||
|
||||
XKBListModel::XKBListModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
{
|
||||
|
@ -146,4 +146,8 @@ public:
|
||||
void setVariants( QMap< QString, QString > variants );
|
||||
};
|
||||
|
||||
/** @brief Adjust to changes in application language.
|
||||
*/
|
||||
void retranslateKeyboardModels();
|
||||
|
||||
#endif // KEYBOARDLAYOUTMODEL_H
|
||||
|
@ -58,10 +58,11 @@ def scrape_file(file, modelsset, layoutsset, variantsset):
|
||||
def write_set(file, label, set):
|
||||
file.write("/* This returns a reference to local, which is a terrible idea.\n * Good thing it's not meant to be compiled.\n */\n")
|
||||
# Note {{ is an escaped { for Python string formatting
|
||||
file.write("static const QStringList& {!s}_table()\n{{\n\treturn QStringList {{\n".format(label))
|
||||
file.write("class {!s} : public QObject {{\nQ_OBJECT\npublic:\n".format(label))
|
||||
file.write("\tconst QStringList& table()\n\t{\n\treturn QStringList {\n")
|
||||
for x in sorted(set):
|
||||
file.write("""\t\tQObject::tr("{!s}", "{!s}"),\n""".format(x, label))
|
||||
file.write("\t\tQString()\n\t};\n}\n\n")
|
||||
file.write("""\t\ttr("{!s}", "{!s}"),\n""".format(x, label))
|
||||
file.write("\t\tQString()\n\t};\n}\n}\n\n")
|
||||
|
||||
cpp_header_comment = """/* GENERATED FILE DO NOT EDIT
|
||||
*
|
||||
@ -84,6 +85,7 @@ if __name__ == "__main__":
|
||||
models=set()
|
||||
layouts=set()
|
||||
variants=set()
|
||||
variants.add( "Default" )
|
||||
with open("/usr/local/share/X11/xkb/rules/base.lst", "r") as f:
|
||||
scrape_file(f, models, layouts, variants)
|
||||
with open("KeyboardData_p.cxxtr", "w") as f:
|
||||
|
Loading…
Reference in New Issue
Block a user