Last active
December 18, 2015 10:18
-
-
Save lurch/5767085 to your computer and use it in GitHub Desktop.
Add a dummy "backwards English" auto-generated translation to https://github.com/raspberrypi/noobs to help with testing localisation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/recovery/create_sdrawkcab_ts.py b/recovery/create_sdrawkcab_ts.py | |
new file mode 100755 | |
index 0000000..1402833 | |
--- /dev/null | |
+++ b/recovery/create_sdrawkcab_ts.py | |
@@ -0,0 +1,27 @@ | |
+#!/usr/bin/env python | |
+import re | |
+import os | |
+ | |
+infilename = 'translation_xx.ts' | |
+if os.path.exists(infilename): | |
+ outfilename = infilename+'.out' | |
+ outfile = open(outfilename, 'w') | |
+ have_translation = False | |
+ for line in open(infilename).readlines(): | |
+ if not have_translation: | |
+ outfile.write(line) | |
+ m1 = re.search('<source>(.*)</source>', line) | |
+ if m1: | |
+ have_translation = True | |
+ source = m1.group(1) | |
+ m2 = re.search('(.*)&(.)(.*)', source) | |
+ if m2: | |
+ translation = "%s&%s%s" % (m2.group(3)[::-1], m2.group(2), m2.group(1)[::-1]) | |
+ else: | |
+ translation = source[::-1] | |
+ translation = re.sub('(\d%|;sopa&)', lambda x: x.group(1)[::-1], translation) | |
+ else: | |
+ have_translation = False | |
+ outfile.write(" <translation>%s</translation>\n" % translation) | |
+ outfile.close() | |
+ os.rename(outfilename, infilename) | |
diff --git a/recovery/icons.qrc b/recovery/icons.qrc | |
index 665df40..8044ead 100644 | |
--- a/recovery/icons.qrc | |
+++ b/recovery/icons.qrc | |
@@ -24,5 +24,6 @@ | |
<file>icons/hu.png</file> | |
<file>translation_fi.qm</file> | |
<file>icons/fi.png</file> | |
+ <file>translation_xx.qm</file> | |
</qresource> | |
</RCC> | |
diff --git a/recovery/languagedialog.cpp b/recovery/languagedialog.cpp | |
index 70e7ef0..63c5c66 100644 | |
--- a/recovery/languagedialog.cpp | |
+++ b/recovery/languagedialog.cpp | |
@@ -53,13 +53,21 @@ LanguageDialog::LanguageDialog(QString *currentLangCode, QWidget *parent) : | |
{ | |
QString langcode = langfile.mid(12); | |
langcode.chop(3); | |
- QLocale loc(langcode); | |
- /* Display languagename in English, e.g. German, French */ | |
- /* QString languagename = QLocale::languageToString(loc.language()); */ | |
- /* should Display languagename in native language, e.g. Deutsch, Français */ | |
- QString languagename = loc.nativeLanguageName(); | |
- QString iconfilename = ":/icons/"+langcode+".png"; | |
+ QString languagename; | |
+ if (langcode == "xx") | |
+ { | |
+ languagename = "sdrawkcaB"; | |
+ } | |
+ else | |
+ { | |
+ QLocale loc(langcode); | |
+ /* Display languagename in English, e.g. German, French */ | |
+ /* QString languagename = QLocale::languageToString(loc.language()); */ | |
+ /* should Display languagename in native language, e.g. Deutsch, Français */ | |
+ languagename = loc.nativeLanguageName(); | |
+ } | |
+ QString iconfilename = ":/icons/"+langcode+".png"; | |
if (QFile::exists(iconfilename)) | |
ui->langCombo->addItem(QIcon(iconfilename), languagename, langcode); | |
else | |
diff --git a/recovery/recovery.pro b/recovery/recovery.pro | |
index 3fd5350..75780d3 100644 | |
--- a/recovery/recovery.pro | |
+++ b/recovery/recovery.pro | |
@@ -50,7 +50,8 @@ TRANSLATIONS += translation_nl.ts \ | |
translation_ja.ts \ | |
translation_fr.ts \ | |
translation_hu.ts \ | |
- translation_fi.ts | |
+ translation_fi.ts \ | |
+ translation_xx.ts | |
OTHER_FILES += \ | |
README.txt | |
diff --git a/recovery/updateqm.sh b/recovery/updateqm.sh | |
index ed9d208..feda09e 100755 | |
--- a/recovery/updateqm.sh | |
+++ b/recovery/updateqm.sh | |
@@ -1,4 +1,4 @@ | |
#!/bin/sh | |
- | |
lupdate -no-obsolete recovery.pro | |
+python create_sdrawkcab_ts.py | |
lrelease recovery.pro |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment