Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use translation files provided by Qt #497

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ jobs:
name: Linux AppImage
runs-on: ubuntu-latest
env:
IMAGE: quay.io/redpanda-cpp/appimage-builder-x86_64:20240304.0
IMAGE: quay.io/redpanda-cpp/appimage-builder-x86_64:20240610.0

steps:
- uses: actions/checkout@v4
Expand Down
13 changes: 11 additions & 2 deletions RedPandaIDE/RedPandaIDE.pro
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,7 @@ RESOURCES += \
codes.qrc \
defaultconfigs.qrc \
icons.qrc \
projecttemplates.qrc \
translations.qrc
projecttemplates.qrc

RC_ICONS = images/devcpp.ico images/associations/c.ico images/associations/cpp.ico images/associations/dev.ico images/associations/c.ico images/associations/cpp.ico images/associations/h.ico images/associations/hpp.ico

Expand All @@ -577,6 +576,16 @@ RESOURCES += iconsets_files
RESOURCES += theme_files
RESOURCES += colorscheme_files

qtConfig(static) {
qt_translation_files.files += $$[QT_INSTALL_TRANSLATIONS]/qtbase_pt_BR.qm
qt_translation_files.files += $$[QT_INSTALL_TRANSLATIONS]/qtbase_zh_CN.qm
qt_translation_files.files += $$[QT_INSTALL_TRANSLATIONS]/qtbase_zh_TW.qm
qt_translation_files.base = $$[QT_INSTALL_TRANSLATIONS]
qt_translation_files.prefix = /translations

RESOURCES += qt_translation_files
}

macos: {
# Add needed executables into the main app bundle
bundled_executable.files = $$OUT_PWD/../tools/consolepauser/consolepauser
Expand Down
10 changes: 9 additions & 1 deletion RedPandaIDE/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QScreen>
#include <QLockFile>
#include <QFontDatabase>
#include <QLibraryInfo>
#include "common.h"
#include "colorscheme.h"
#include "iconsmanager.h"
Expand Down Expand Up @@ -349,7 +350,14 @@ int main(int argc, char *argv[])
if (transUtils.load("qt_utils_"+language,":/i18n/")) {
app.installTranslator(&transUtils);
}
if (transQt.load("qt_"+language,":/translations")) {
QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
if (
// since Qt 5.15.3, `qt_xx.qm` is a wrapper for `qtbase_xx.qm` and other (unused) `qm`s.
// first, try loading `qt_xx.qm` from standard location (dynamic build) so that it works on Debian 11 (with Qt 5.15.2),
transQt.load("qt_" + language, translationsPath) ||
// and then bundled `qtbase_xx.qm` (static build) for simplicity in qmake project.
transQt.load("qtbase_" + language, ":/translations")
) {
app.installTranslator(&transQt);
}
}
Expand Down
5 changes: 0 additions & 5 deletions RedPandaIDE/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@
#include <windows.h>
#endif

static const char *Translation[] =
{
QT_TRANSLATE_NOOP("QFileSystemModel", "<b>The name \"%1\" cannot be used.</b><p>Try using another name, with fewer characters or no punctuation marks.")
};

static int findTabIndex(QTabWidget* tabWidget , QWidget* w) {
for (int i=0;i<tabWidget->count();i++) {
if (w==tabWidget->widget(i))
Expand Down
Binary file removed RedPandaIDE/qt_zh_CN.qm
Binary file not shown.
5 changes: 0 additions & 5 deletions RedPandaIDE/translations.qrc

This file was deleted.

8 changes: 0 additions & 8 deletions RedPandaIDE/translations/RedPandaIDE_pt_BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8430,14 +8430,6 @@
<translation type="obsolete">Configurações</translation>
</message>
</context>
<context>
<name>QFileSystemModel</name>
<message>
<location filename="../mainwindow.cpp" line="-1212"/>
<source>&lt;b&gt;The name &quot;%1&quot; cannot be used.&lt;/b&gt;&lt;p&gt;Try using another name, with fewer characters or no punctuation marks.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
Expand Down
8 changes: 0 additions & 8 deletions RedPandaIDE/translations/RedPandaIDE_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9142,14 +9142,6 @@ p, li { white-space: pre-wrap; }
<translation type="obsolete">编译/链接选项</translation>
</message>
</context>
<context>
<name>QFileSystemModel</name>
<message>
<location filename="../mainwindow.cpp" line="-6454"/>
<source>&lt;b&gt;The name &quot;%1&quot; cannot be used.&lt;/b&gt;&lt;p&gt;Try using another name, with fewer characters or no punctuation marks.</source>
<translation>&lt;b&gt;文件名 &quot;%1&quot; 无法被使用!&lt;/b&gt;&lt;p&gt;可能是重名、过长、为空或者是使用了不能出现在文件名里的符号。</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
Expand Down
8 changes: 0 additions & 8 deletions RedPandaIDE/translations/RedPandaIDE_zh_TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7890,14 +7890,6 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QFileSystemModel</name>
<message>
<location filename="../mainwindow.cpp" line="-1212"/>
<source>&lt;b&gt;The name &quot;%1&quot; cannot be used.&lt;/b&gt;&lt;p&gt;Try using another name, with fewer characters or no punctuation marks.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
Expand Down
2 changes: 1 addition & 1 deletion docs/detailed-build-win-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ qmake 变量:
3. 用 vcpkg 安装 Qt。
```ps1
$TARGET = "x64-windows-static" # 或 "x86-windows-static"
vcpkg install qt5-base:$TARGET qt5-svg:$TARGET qt5-tools:$TARGET
vcpkg install qt5-base:$TARGET qt5-svg:$TARGET qt5-tools:$TARGET qt5-translations:$TARGET
```

在 PowerShell (Core) 或 Windows PowerShell 中用 VS 2019 或更高版本构建:
Expand Down
2 changes: 1 addition & 1 deletion docs/detailed-build-win.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Prerequisites:
3. Install Qt with vcpkg.
```ps1
$TARGET = "x64-windows-static" # or "x86-windows-static"
vcpkg install qt5-base:$TARGET qt5-svg:$TARGET qt5-tools:$TARGET
vcpkg install qt5-base:$TARGET qt5-svg:$TARGET qt5-tools:$TARGET qt5-translations:$TARGET
```

To build with VS 2019 or later in PowerShell (Core) or Windows PowerShell:
Expand Down
Loading