Skip to content

Commit

Permalink
fix: Add translation function (#141)
Browse files Browse the repository at this point in the history
Log: fix: Add translation function
  • Loading branch information
JWWTSL authored Feb 18, 2025
1 parent 145e2e0 commit 43696d8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
15 changes: 14 additions & 1 deletion deepin_reader.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ TEMPLATE = subdirs

#QMAKE_CXX = ccache $$QMAKE_CXX //linux使用ccache加速c++编译速度
#config

# 基础 Qt 模块
equals(QT_MAJOR_VERSION, 6) {
versionAtLeast(QT_VERSION, 6.0.0) {
QT += core gui widgets network dbus sql svg webchannel webenginewidgets concurrent xml core5compat

# Qt6 specific configurations
Expand Down Expand Up @@ -52,3 +53,15 @@ SUBDIRS += htmltopdf

SUBDIRS += reader

# Execute translation script with Qt version parameter
versionAtLeast(QT_VERSION, 6.0.0) {
system($$PWD/translate_generation.sh 6)
} else {
system($$PWD/translate_generation.sh 5)
}

# Install translations
translations.path = $$PREFIX/share/deepin-reader/translations
translations.files = $$PWD/translations/*.qm
INSTALLS += translations

18 changes: 16 additions & 2 deletions translate_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@
# this file is used to auto-generate .qm file from .ts file.
# author: shibowen at linuxdeepin.com

# 获取传入的QT版本参数
QT_VERSION_MAJOR=$1

# 确保QT_VERSION_MAJOR是一个整数
if ! [[ "$QT_VERSION_MAJOR" =~ ^[0-9]+$ ]]; then
echo "Error: QT_VERSION_MAJOR is not a valid integer."
exit 1
fi

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

for ts in "${ts_list[@]}"
do
printf "\nprocess ${ts}\n"
lrelease "${ts}"
done
# 根据QT版本选择lrelease命令
if [ "$QT_VERSION_MAJOR" -eq 6 ]; then
/usr/lib/qt6/bin/lrelease "${ts}"
else
lrelease "${ts}"
fi
done

0 comments on commit 43696d8

Please sign in to comment.