]> git.pld-linux.org Git - packages/clementine.git/blob - unbundle-po.patch
7bba8cd6d9dee5c5d41fdebd1a86f7ad8f1bdbdb
[packages/clementine.git] / unbundle-po.patch
1 Do not bundle translations with a binary,
2 package them to system dir and use %lang tagging in package.
3
4 some paths debug:
5   qWarning() << "language: " << language;
6   qWarning() << "qtpath: " << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
7   qWarning() << "apppath: " << a.applicationDirPath();
8   qWarning() << "curdir: " << QDir::currentPath();
9
10 TODO: add install target
11 TODO: make it configurable via cmake params.
12
13 Author: 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
42 --- clementine-0.5.3/src/ui/behavioursettingspage.cpp~  2010-10-19 11:24:36.488320486 +0300
43 +++ clementine-0.5.3/src/ui/behavioursettingspage.cpp   2010-10-19 11:24:40.594127569 +0300
44 @@ -21,6 +21,7 @@
45  #include "playlist/playlist.h"
46  
47  #include <QDir>
48 +#include <QLibraryInfo>
49  
50  
51  BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog* dialog)
52 @@ -93,15 +93,22 @@
53  
54    // Populate the language combo box.  We do this by looking at all the
55    // compiled in translations.
56 -  QDir dir(":/translations/");
57 -  QStringList codes(dir.entryList(QStringList() << "*.qm"));
58 -  QRegExp lang_re("^clementine_(.*).qm$");
59 -  foreach (const QString& filename, codes) {
60 -    // The regex captures the "ru" from "clementine_ru.qm"
61 -    if (!lang_re.exactMatch(filename))
62 +//  QDir dir(":/translations/");
63 +  QDir localeDir(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
64 +  QStringList dirList = localeDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
65 +  foreach (const QString& code, dirList) {
66 +    if (!QFile::exists(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/" + code + "/LC_MESSAGES/clementine.qm")) {
67        continue;
68 +    }
69  
70 -    QString code = lang_re.cap(1);
71 +//  QStringList codes(dir.entryList(QStringList() << "*.qm"));
72 +//  QRegExp lang_re("^clementine_(.*).qm$");
73 +//  foreach (const QString& filename, codes) {
74 +//    // The regex captures the "ru" from "clementine_ru.qm"
75 +//    if (!lang_re.exactMatch(filename))
76 +//      continue;
77 +
78 +//    QString code = lang_re.cap(1);
79      QString name = QString("%1 (%2)").arg(
80          QLocale::languageToString(QLocale(code).language()), code);
81  
82 --- clementine-0.5.3/cmake/Translations.cmake   2010-10-18 23:59:53.487509786 +0300
83 +++ clementine-0.5.3/cmake/Translations.cmake   2010-10-19 01:42:52.112825900 +0300
84 @@ -65,10 +65,22 @@
85  
86 -  # Generate a qrc file for the translations
87 -  set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc)
88 -  file(WRITE ${_qrc} "<RCC><qresource prefix=\"/${ADD_PO_DIRECTORY}\">")
89 -  foreach(_lang ${ADD_PO_LANGUAGES})
90 -    file(APPEND ${_qrc} "<file>${po_prefix}${_lang}.qm</file>")
91 -  endforeach(_lang)
92 -  file(APPEND ${_qrc} "</qresource></RCC>")
93 -  qt4_add_resources(${outfiles} ${_qrc})
94 +  # install .qm
95 +  set(_potBasename "clementine")
96 +  foreach (_lang ${ADD_PO_LANGUAGES})
97 +    set(_qm_filename "clementine_${_lang}.qm")
98 +    set(_qm_filepath "${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/${_qm_filename}")
99 +
100 +    install(FILES ${_qm_filepath} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.qm)
101 +    set(_gmoFiles ${_gmoFiles} ${_gmoFile})
102 +  endforeach (_lang)
103 +
104 +  add_custom_target(translations ALL DEPENDS ${_gmoFiles})
105 +
106 +#  # Generate a qrc file for the translations
107 +#  set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc)
108 +#  file(WRITE ${_qrc} "<RCC><qresource prefix=\"/${ADD_PO_DIRECTORY}\">")
109 +#  foreach(_lang ${ADD_PO_LANGUAGES})
110 +#    file(APPEND ${_qrc} "<file>${po_prefix}${_lang}.qm</file>")
111 +#  endforeach(_lang)
112 +#  file(APPEND ${_qrc} "</qresource></RCC>")
113 +#  qt4_add_resources(${outfiles} ${_qrc})
114  endmacro(add_po)
115 --- clementine-1.1.1/tests/resources_env.h~     2013-09-08 01:29:59.000000000 +0300
116 +++ clementine-1.1.1/tests/resources_env.h      2013-09-08 01:30:00.886424405 +0300
117 @@ -26,7 +26,7 @@
118  public:
119    void SetUp() {
120      Q_INIT_RESOURCE(data);
121 -    Q_INIT_RESOURCE(translations);
122 +//    Q_INIT_RESOURCE(translations);
123      Q_INIT_RESOURCE(testdata);
124    }
125  };
126 --- clementine-1.1.1/tests/translations_test.cpp~       2013-09-08 01:34:17.000000000 +0300
127 +++ clementine-1.1.1/tests/translations_test.cpp        2013-09-08 01:34:21.084475375 +0300
128 @@ -23,14 +23,14 @@
129  #include "test_utils.h"
130  
131  TEST(Translations, Basic) {
132 -  ASSERT_TRUE(QFile::exists(":/translations"));
133 -  ASSERT_TRUE(QFile::exists(":/translations/clementine_es.qm"));
134 +//  ASSERT_TRUE(QFile::exists(":/translations"));
135 +//  ASSERT_TRUE(QFile::exists(":/translations/clementine_es.qm"));
136  
137    PoTranslator t;
138    t.load("clementine_es.qm", ":/translations");
139  
140 -  EXPECT_EQ(QString::fromUtf8("Colección"),
141 -            t.translate("MainWindow", "Library"));
142 -  EXPECT_EQ(QString::fromUtf8("Colección"),
143 -            t.translate("", "Library"));
144 +//  EXPECT_EQ(QString::fromUtf8("Colección"),
145 +//            t.translate("MainWindow", "Library"));
146 +//  EXPECT_EQ(QString::fromUtf8("Colección"),
147 +//            t.translate("", "Library"));
148  }
This page took 0.047996 seconds and 2 git commands to generate.