]> git.pld-linux.org Git - packages/clementine.git/blame - unbundle-po.patch
- unbundle translations, tag with %lang
[packages/clementine.git] / unbundle-po.patch
CommitLineData
a127fee1
ER
1Do not bundle translations with a binary,
2package them to system dir and use %lang tagging in package.
3
4some paths debug:
5 qWarning() << "language: " << language;
6 qWarning() << "qtpath: " << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
7 qWarning() << "apppath: " << a.applicationDirPath();
8 qWarning() << "curdir: " << QDir::currentPath();
9
10TODO: add install target
11TODO: make it configurable via cmake params.
12
13Author: Elan Ruusamäe <glen@pld-linux.org>
14
15--- clementine-0.5.3/src/main.cpp~ 2010-10-18 23:59:12.000000000 +0300
16+++ clementine-0.5.3/src/main.cpp 2010-10-18 23:59:15.876170584 +0300
17@@ -176,7 +176,7 @@
18
19 // Resources
20 Q_INIT_RESOURCE(data);
21- Q_INIT_RESOURCE(translations);
22+ //Q_INIT_RESOURCE(translations);
23
24 // Has the user forced a different language?
25 QString language = options.language();
26@@ -187,9 +187,15 @@
27 }
28
29 // Translations
30+ // Qt: system path
31 LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
32+ // Clementine: system path
33+ LoadTranslation("clementine", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
34+ // Clementine: QRC
35 LoadTranslation("clementine", ":/translations", language);
36+ // Clementine: application path
37 LoadTranslation("clementine", a.applicationDirPath(), language);
38+ // Clementine: current dir
39 LoadTranslation("clementine", QDir::currentPath(), language);
40
41 // Icons
9400a97a
ER
42--- clementine-0.5.3/src/ui/settingsdialog.cpp~ 2010-10-19 11:24:36.488320486 +0300
43+++ clementine-0.5.3/src/ui/settingsdialog.cpp 2010-10-19 11:24:40.594127569 +0300
44@@ -93,15 +93,22 @@
45
46 // Populate the language combo box. We do this by looking at all the
47 // compiled in translations.
48- QDir dir(":/translations/");
49- QStringList codes(dir.entryList(QStringList() << "*.qm"));
50- QRegExp lang_re("^clementine_(.*).qm$");
51- foreach (const QString& filename, codes) {
52- // The regex captures the "ru" from "clementine_ru.qm"
53- if (!lang_re.exactMatch(filename))
54+// QDir dir(":/translations/");
8130efd6 55+ QDir localeDir(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
9400a97a
ER
56+ QStringList dirList = localeDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
57+ foreach (const QString& code, dirList) {
8130efd6 58+ if (!QFile::exists(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/" + code + "/LC_MESSAGES/clementine.qm")) {
9400a97a
ER
59 continue;
60+ }
61
62- QString code = lang_re.cap(1);
63+// QStringList codes(dir.entryList(QStringList() << "*.qm"));
64+// QRegExp lang_re("^clementine_(.*).qm$");
65+// foreach (const QString& filename, codes) {
66+// // The regex captures the "ru" from "clementine_ru.qm"
67+// if (!lang_re.exactMatch(filename))
68+// continue;
69+
70+// QString code = lang_re.cap(1);
71 QString name = QString("%1 (%2)").arg(
72 QLocale::languageToString(QLocale(code).language()), code);
73
0016e833
ER
74--- clementine-0.5.3/cmake/Translations.cmake 2010-10-18 23:59:53.487509786 +0300
75+++ clementine-0.5.3/cmake/Translations.cmake 2010-10-19 01:42:52.112825900 +0300
76@@ -65,10 +65,22 @@
a127fee1
ER
77
78- # Generate a qrc file for the translations
79- set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc)
80- file(WRITE ${_qrc} "<RCC><qresource prefix=\"/${ADD_PO_DIRECTORY}\">")
81- foreach(_lang ${ADD_PO_LANGUAGES})
82- file(APPEND ${_qrc} "<file>${po_prefix}${_lang}.qm</file>")
83- endforeach(_lang)
84- file(APPEND ${_qrc} "</qresource></RCC>")
85- qt4_add_resources(${outfiles} ${_qrc})
0016e833
ER
86+ # install .qm
87+ set(_potBasename "clementine")
88+ foreach (_lang ${ADD_PO_LANGUAGES})
89+ set(_qm_filename "clementine_${_lang}.qm")
90+ set(_qm_filepath "${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/${_qm_filename}")
91+
92+ install(FILES ${_qm_filepath} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.qm)
93+ set(_gmoFiles ${_gmoFiles} ${_gmoFile})
94+ endforeach (_lang)
95+
96+ add_custom_target(translations ALL DEPENDS ${_gmoFiles})
97+
a127fee1
ER
98+# # Generate a qrc file for the translations
99+# set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc)
100+# file(WRITE ${_qrc} "<RCC><qresource prefix=\"/${ADD_PO_DIRECTORY}\">")
101+# foreach(_lang ${ADD_PO_LANGUAGES})
102+# file(APPEND ${_qrc} "<file>${po_prefix}${_lang}.qm</file>")
103+# endforeach(_lang)
104+# file(APPEND ${_qrc} "</qresource></RCC>")
105+# qt4_add_resources(${outfiles} ${_qrc})
106 endmacro(add_po)
This page took 0.054429 seconds and 4 git commands to generate.