]> git.pld-linux.org Git - packages/clementine.git/blob - unbundle-po.patch
Release 24 (by relup.sh)
[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-1.3.1/src/main.cpp.orig  2016-04-19 17:43:09.000000000 +0200
16 +++ clementine-1.3.1/src/main.cpp       2022-07-09 07:56:27.319171455 +0200
17 @@ -396,7 +396,6 @@ int main(int argc, char* argv[]) {
18  
19    // Resources
20    Q_INIT_RESOURCE(data);
21 -  Q_INIT_RESOURCE(translations);
22  
23    // Add root CA cert for SoundCloud, whose certificate is missing on OS X.
24    QSslSocket::addDefaultCaCertificates(
25 @@ -417,10 +416,15 @@ int main(int argc, char* argv[]) {
26                                 : override_language;
27  
28    // Translations
29 -  LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath),
30 -                  language);
31 +  // Qt: system path
32 +  LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
33 +  // Clementine: system path
34 +  LoadTranslation("clementine", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
35 +  // Clementine: QRC
36    LoadTranslation("clementine", ":/translations", language);
37 +  // Clementine: application path
38    LoadTranslation("clementine", a.applicationDirPath(), language);
39 +  // Clementine: current dir
40    LoadTranslation("clementine", QDir::currentPath(), language);
41  
42  #ifdef Q_OS_WIN32
43 --- clementine-1.3.1/src/ui/behavioursettingspage.cpp.orig      2015-12-15 13:13:23.000000000 +0100
44 +++ clementine-1.3.1/src/ui/behavioursettingspage.cpp   2022-07-09 07:58:06.261968769 +0200
45 @@ -23,6 +23,7 @@
46  #include "playlist/playlisttabbar.h"
47  
48  #include <QDir>
49 +#include <QLibraryInfo>
50  
51  namespace {
52  bool LocaleAwareCompare(const QString& a, const QString& b) {
53 @@ -59,16 +60,15 @@ BehaviourSettingsPage::BehaviourSettings
54    ui_->menu_previousmode->setItemData(0, Player::PreviousBehaviour_DontRestart);
55    ui_->menu_previousmode->setItemData(1, Player::PreviousBehaviour_Restart);
56  
57 -  // Populate the language combo box.  We do this by looking at all the
58 -  // compiled in translations.
59 -  QDir dir(":/translations/");
60 -  QStringList codes(dir.entryList(QStringList() << "*.qm"));
61 -  QRegExp lang_re("^clementine_(.*).qm$");
62 -  for (const QString& filename : codes) {
63 -    // The regex captures the "ru" from "clementine_ru.qm"
64 -    if (!lang_re.exactMatch(filename)) continue;
65 +  // Populate the language combo box
66 +  // We do this by looking at all the compiled in translations.
67 +  QDir localeDir(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
68 +  QStringList dirList = localeDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
69 +  foreach (const QString& code, dirList) {
70 +    if (!QFile::exists(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/" + code + "/LC_MESSAGES/clementine.qm")) {
71 +       continue;
72 +    }
73  
74 -    QString code = lang_re.cap(1);
75      QString lookup_code = QString(code)
76                                .replace("@latin", "_Latn")
77                                .replace("_CN", "_Hans_CN")
78 --- clementine-0.5.3/cmake/Translations.cmake   2010-10-18 23:59:53.487509786 +0300
79 +++ clementine-0.5.3/cmake/Translations.cmake   2010-10-19 01:42:52.112825900 +0300
80 @@ -65,10 +65,22 @@
81  
82 -  # Generate a qrc file for the translations
83 -  set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc)
84 -  file(WRITE ${_qrc} "<RCC><qresource prefix=\"/${ADD_PO_DIRECTORY}\">")
85 -  foreach(_lang ${ADD_PO_LANGUAGES})
86 -    file(APPEND ${_qrc} "<file>${po_prefix}${_lang}.qm</file>")
87 -  endforeach(_lang)
88 -  file(APPEND ${_qrc} "</qresource></RCC>")
89 -  qt4_add_resources(${outfiles} ${_qrc})
90 +  # install .qm
91 +  set(_potBasename "clementine")
92 +  foreach (_lang ${ADD_PO_LANGUAGES})
93 +    set(_qm_filename "clementine_${_lang}.qm")
94 +    set(_qm_filepath "${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/${_qm_filename}")
95 +
96 +    install(FILES ${_qm_filepath} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.qm)
97 +    set(_gmoFiles ${_gmoFiles} ${_gmoFile})
98 +  endforeach (_lang)
99 +
100 +  add_custom_target(translations ALL DEPENDS ${_gmoFiles})
101 +
102 +#  # Generate a qrc file for the translations
103 +#  set(_qrc ${CMAKE_CURRENT_BINARY_DIR}/${ADD_PO_DIRECTORY}/translations.qrc)
104 +#  file(WRITE ${_qrc} "<RCC><qresource prefix=\"/${ADD_PO_DIRECTORY}\">")
105 +#  foreach(_lang ${ADD_PO_LANGUAGES})
106 +#    file(APPEND ${_qrc} "<file>${po_prefix}${_lang}.qm</file>")
107 +#  endforeach(_lang)
108 +#  file(APPEND ${_qrc} "</qresource></RCC>")
109 +#  qt4_add_resources(${outfiles} ${_qrc})
110  endmacro(add_po)
111 --- clementine-1.1.1/tests/resources_env.h~     2013-09-08 01:29:59.000000000 +0300
112 +++ clementine-1.1.1/tests/resources_env.h      2013-09-08 01:30:00.886424405 +0300
113 @@ -26,7 +26,7 @@
114  public:
115    void SetUp() {
116      Q_INIT_RESOURCE(data);
117 -    Q_INIT_RESOURCE(translations);
118 +//    Q_INIT_RESOURCE(translations);
119      Q_INIT_RESOURCE(testdata);
120    }
121  };
122 --- clementine-1.1.1/tests/translations_test.cpp~       2013-09-08 01:34:17.000000000 +0300
123 +++ clementine-1.1.1/tests/translations_test.cpp        2013-09-08 01:34:21.084475375 +0300
124 @@ -23,14 +23,14 @@
125  #include "test_utils.h"
126  
127  TEST(Translations, Basic) {
128 -  ASSERT_TRUE(QFile::exists(":/translations"));
129 -  ASSERT_TRUE(QFile::exists(":/translations/clementine_es.qm"));
130 +//  ASSERT_TRUE(QFile::exists(":/translations"));
131 +//  ASSERT_TRUE(QFile::exists(":/translations/clementine_es.qm"));
132  
133    PoTranslator t;
134    t.load("clementine_es.qm", ":/translations");
135  
136 -  EXPECT_EQ(QString::fromUtf8("Colección"),
137 -            t.translate("MainWindow", "Library"));
138 -  EXPECT_EQ(QString::fromUtf8("Colección"),
139 -            t.translate("", "Library"));
140 +//  EXPECT_EQ(QString::fromUtf8("Colección"),
141 +//            t.translate("MainWindow", "Library"));
142 +//  EXPECT_EQ(QString::fromUtf8("Colección"),
143 +//            t.translate("", "Library"));
144  }
This page took 0.100746 seconds and 4 git commands to generate.