Page MenuHomePhorge

D110.1732613534.diff
No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None

D110.1732613534.diff

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,11 +1,8 @@
-set(KAZV_DATA_DIR ${KDE_INSTALL_DATADIR}/kazv)
-set(KAZV_L10N_DIR ${KAZV_DATA_DIR}/l10n)
if(WIN32)
set(KAZV_IS_WINDOWS 1)
else()
set(KAZV_IS_WINDOWS 0)
endif()
-configure_file(kazv-path-config.hpp.in kazv-path-config.hpp)
configure_file(kazv-version.cpp.in kazv-version.cpp)
configure_file(kazv-platform.hpp.in kazv-platform.hpp)
configure_file(kazv-defs.hpp.in kazv-defs.hpp)
@@ -41,6 +38,7 @@
device-mgmt/matrix-device-list.cpp
kazv-config.cpp
+ kazv-path-config.cpp
kazv-io-manager.cpp
kazv-io-job.cpp
kazv-file.cpp
@@ -83,6 +81,7 @@
set(kazv_SRCS
main.cpp
resources.qrc
+ l10n/translations.qrc
)
add_executable(kazv ${kazv_SRCS})
@@ -96,10 +95,5 @@
set(kazv_INSTALL_ARGS ${KF${KF_MAJOR_VERSION}_INSTALL_TARGETS_DEFAULT_ARGS})
endif()
install(TARGETS kazv ${kazv_INSTALL_ARGS})
-install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/l10n/
- DESTINATION ${KAZV_L10N_DIR}
- FILES_MATCHING PATTERN "*.ftl"
- PATTERN "*.json"
- )
add_subdirectory(tests)
diff --git a/src/kazv-path-config.hpp b/src/kazv-path-config.hpp
new file mode 100644
--- /dev/null
+++ b/src/kazv-path-config.hpp
@@ -0,0 +1,14 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2021-2024 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <kazv-defs.hpp>
+#include <QString>
+
+QString appDir();
+
+QString kazvUserDataDir();
diff --git a/src/kazv-path-config.hpp.in b/src/kazv-path-config.hpp.in
deleted file mode 100644
--- a/src/kazv-path-config.hpp.in
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * This file is part of kazv.
- * SPDX-FileCopyrightText: 2021-2024 tusooa <tusooa@kazv.moe>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-#pragma once
-
-#include <kazv-defs.hpp>
-
-#include <QString>
-#include <QCoreApplication>
-#include <QStandardPaths>
-#include <QDir>
-#include <filesystem>
-
-namespace KazvPathConfigDetail
-{
- inline QString dirName(QString dir)
- {
- QDir d(dir);
- d.cdUp();
- return d.absolutePath();
- }
-
- inline QString pathJoin(QString dir, QString file)
- {
- using StdPath = std::filesystem::path;
-
- return QString::fromStdString((StdPath(dir.toStdString()) / StdPath(file.toStdString())).string());
- }
-}
-
-inline QString appDir()
-{
- static QString dir = QCoreApplication::applicationDirPath();
- return dir;
-}
-
-inline QString installPrefixDir()
-{
- static QString dir = KazvPathConfigDetail::dirName(appDir());
- return dir;
-}
-
-inline QString kazvDataDir()
-{
- static QString dir = KazvPathConfigDetail::pathJoin(installPrefixDir(), QString(R"xxx(${KAZV_DATA_DIR})xxx"));
- return dir;
-}
-
-inline QString kazvL10nDir()
-{
- static QString dir = KazvPathConfigDetail::pathJoin(installPrefixDir(), QString(R"xxx(${KAZV_L10N_DIR})xxx"));
- return dir;
-}
-
-inline QString kazvUserDataDir()
-{
- static QString dir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
- return dir;
-}
diff --git a/src/kazv-path-config.cpp b/src/kazv-path-config.cpp
new file mode 100644
--- /dev/null
+++ b/src/kazv-path-config.cpp
@@ -0,0 +1,21 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2021-2024 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+#include <kazv-defs.hpp>
+#include "kazv-path-config.hpp"
+#include <QCoreApplication>
+#include <QStandardPaths>
+
+QString appDir()
+{
+ return QCoreApplication::applicationDirPath();
+}
+
+QString kazvUserDataDir()
+{
+ static QString dir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
+ return dir;
+}
diff --git a/src/l10n-provider.cpp b/src/l10n-provider.cpp
--- a/src/l10n-provider.cpp
+++ b/src/l10n-provider.cpp
@@ -13,19 +13,19 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QStringBuilder>
+#include <QDir>
#include <stdexcept>
#include "kazv-path-config.hpp"
static QString l10nConfigFile()
{
- static QString file = KazvPathConfigDetail::pathJoin(kazvL10nDir(), QString("config.json"));
- return file;
+ return QString(":/l10n/config.json");
}
static QString dirForLocale(QString locale)
{
- return KazvPathConfigDetail::pathJoin(kazvL10nDir(), locale);
+ return QString(":/l10n/") + locale;
}
static QString readWholeFile(QString path)
diff --git a/src/l10n/translations.qrc b/src/l10n/translations.qrc
new file mode 100644
--- /dev/null
+++ b/src/l10n/translations.qrc
@@ -0,0 +1,14 @@
+<RCC>
+ <qresource prefix="/l10n">
+ <file>config.json</file>
+ <file>en/010-kazv-terms.ftl</file>
+ <file>en/100-ui.ftl</file>
+ <file>cmn-Hans/010-kazv-terms.ftl</file>
+ <file>cmn-Hans/100-ui.ftl</file>
+ <file>hi/010-kazv-terms.ftl</file>
+ <file>hi/100-ui.ftl</file>
+ <!-- The following is used for the systems where symlink is not well-supported. -->
+ <file alias="zh-Hans/010-kazv-terms.ftl">cmn-Hans/010-kazv-terms.ftl</file>
+ <file alias="zh-Hans/100-ui.ftl">cmn-Hans/100-ui.ftl</file>
+ </qresource>
+</RCC>

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 1:32 AM (13 h, 4 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39888
Default Alt Text
D110.1732613534.diff (5 KB)

Event Timeline