Skip to content

Commit

Permalink
Modified the path of translated pm files and the timing of generation
Browse files Browse the repository at this point in the history
  • Loading branch information
eightplus committed Aug 12, 2019
1 parent 7fe0c15 commit 33fbbc4
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 30 deletions.
3 changes: 1 addition & 2 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
#! /bin/sh
# Run this to generate all the initial makefiles, etc.

#lrelease src/src.pro
lrelease kylin-video.pro
4 changes: 3 additions & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
kylin-video (2.0.0-0ubuntu2) eoan; urgency=low

* Supported Interface Size Tension.
* Added new files, such as videowindow.cpp, autohidecursorwidget.cpp and displaylayercomposer.cpp.
* Added new files, such as videowindow.cpp, autohidecursorwidget.cpp and
displaylayercomposer.cpp.
* Add remote controller dbus.
* Add equalizer and filter for audio.
* Fixed the exception of the esctip.
* Access icon from theme.
* Modified the path of translated pm files and the timing of generation.

-- lixiang <lixiang@kylinos.cn> Mon, 22 Jul 2019 10:51:05 +0800

Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ override_dh_auto_configure:
dh $@

override_dh_install:
./autogen.sh
# ./autogen.sh
dh_install

override_dh_missing:
Expand Down
6 changes: 0 additions & 6 deletions src/res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,4 @@
<qresource prefix="/qss">
<file>res/style.qss</file>
</qresource>
<qresource prefix="/qm">
<file>translations/kylin-video_zh_CN.qm</file>
<file>translations/kylin-video_fr.qm</file>
<file>translations/kylin-video_pt.qm</file>
<file>translations/kylin-video_ru.qm</file>
</qresource>
</RCC>
6 changes: 2 additions & 4 deletions src/smplayer/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ QString Paths::appPath() {

QString Paths::translationPath()
{
return ":/qm/translations";

/*QString path;
QString path;
if (QDir("/usr/share/kylin-video/translations").exists()) {
path = "/usr/share/kylin-video/translations";
return path;
}
else {
return appPath() + "/translations";
}*/
}
}

QString Paths::shortcutsPath() {
Expand Down
28 changes: 12 additions & 16 deletions src/smplayer/translator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,32 @@
#include <QApplication>
#include <QDebug>

Translator::Translator() {
qApp->installTranslator( &app_trans );
qApp->installTranslator( &qt_trans );
Translator::Translator()
{
qApp->installTranslator(&app_trans);
qApp->installTranslator(&qt_trans);
}

Translator::~Translator() {
Translator::~Translator()
{
}

bool Translator::loadCatalog(QTranslator & t, QString name, QString locale, QString dir) {
bool Translator::loadCatalog(QTranslator & t, QString name, QString locale, QString dir)
{
QString s = name + "_" + locale + ".qm"; //.toLower();
bool r = t.load(s, dir);
if (r) {
// qDebug("Translator::loadCatalog: successfully loaded %s from %s", s.toUtf8().data(), dir.toUtf8().data());
}
else {
if (!r) {
qDebug("Translator::loadCatalog: can't load %s from %s", s.toUtf8().data(), dir.toUtf8().data());
}
return r;
}

void Translator::load(const QString &snap/*QString locale*/) {
void Translator::load(const QString &snap)
{
QString locale = QLocale::system().name();

QString trans_path = Paths::translationPath();
//edited by kobe 20160823

QString qt_trans_path;
if (!snap.isEmpty()) {
qt_trans_path = QString("%1%2").arg(snap).arg(Paths::qtTranslationPath());
Expand All @@ -56,11 +57,6 @@ void Translator::load(const QString &snap/*QString locale*/) {
qt_trans_path = Paths::qtTranslationPath();
}

// In linux try to load it first from app path (in case there's an updated
// translation), if it fails it will try then from the Qt path.
// if (! loadCatalog(qt_trans, "qt", locale, trans_path ) ) {
loadCatalog(qt_trans, "qt", locale, qt_trans_path);
// }

loadCatalog(app_trans, "kylin-video", locale, trans_path);
}
4 changes: 4 additions & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ RESOURCES = res.qrc

DEFINES += SINGLE_INSTANCE

!system($$PWD/translations/generate_translations_pm.sh): error("Failed to generate pm")
qm_files.files = translations/*.qm
qm_files.path = /usr/share/kylin-video/translations/
inst1.files += res/kylin-video.png
inst1.path = /usr/share/pixmaps
inst2.files += ../kylin-video.desktop
Expand All @@ -21,6 +24,7 @@ target.source += $$TARGET
target.path = /usr/bin
INSTALLS += inst1 \
inst2 \
qm_files \
target

QMAKE_CPPFLAGS *= $(shell dpkg-buildflags --get CPPFLAGS)
Expand Down
8 changes: 8 additions & 0 deletions src/translations/generate_translations_pm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /bin/bash

ts_file_list=(`ls translations/*.ts`)

for ts in "${ts_file_list[@]}"
do
lrelease "${ts}"
done

0 comments on commit 33fbbc4

Please sign in to comment.