translation of all project, and new translation mechanism

This commit is contained in:
2026-09-03 09:18:48 +03:00
parent 00e7c957e4
commit 01af372ef2
32 changed files with 2813 additions and 537 deletions
+9 -8
View File
@@ -1,4 +1,5 @@
#include "minecraftversion.h"
#include "localization.h"
#include <QDir>
#include <QDirIterator>
@@ -373,7 +374,7 @@ bool VersionLoader::remove(const QString &gameDir, const QString &versionId, QSt
const QString root = versionsRoot(gameDir);
if (gameDir.isEmpty() || !isSafeVersionId(versionId)) {
if (error)
*error = QObject::tr("недопустимый идентификатор версии");
*error = Loc::text("version.error.invalidId");
return false;
}
@@ -382,14 +383,14 @@ bool VersionLoader::remove(const QString &gameDir, const QString &versionId, QSt
const QString dir = QDir::cleanPath(root + u'/' + versionId);
if (!dir.startsWith(root + u'/')) {
if (error)
*error = QObject::tr("недопустимый идентификатор версии");
*error = Loc::text("version.error.invalidId");
return false;
}
if (!QDir(dir).exists())
return true;
if (!QDir(dir).removeRecursively()) {
if (error)
*error = QObject::tr("не удалось удалить %1").arg(QDir::toNativeSeparators(dir));
*error = Loc::text("common.error.removeFailed").arg(QDir::toNativeSeparators(dir));
return false;
}
return true;
@@ -410,12 +411,12 @@ MinecraftVersion VersionLoader::load(const QString &gameDir,
while (!currentId.isEmpty()) {
if (chainIds.contains(currentId)) {
if (error)
*error = QObject::tr("Циклическая зависимость inheritsFrom в версии «%1»").arg(currentId);
*error = Loc::text("version.error.inheritsCycle").arg(currentId);
return version;
}
if (chain.size() >= kMaxInheritanceDepth) {
if (error)
*error = QObject::tr("Слишком длинная цепочка inheritsFrom у версии «%1»").arg(versionId);
*error = Loc::text("common.error.inheritsChainTooLong").arg(versionId);
return version;
}
@@ -423,7 +424,7 @@ MinecraftVersion VersionLoader::load(const QString &gameDir,
QFile file(path);
if (!file.open(QIODevice::ReadOnly)) {
if (error)
*error = QObject::tr("Не найден файл версии: %1").arg(QDir::toNativeSeparators(path));
*error = Loc::text("version.error.fileMissing").arg(QDir::toNativeSeparators(path));
return version;
}
@@ -431,7 +432,7 @@ MinecraftVersion VersionLoader::load(const QString &gameDir,
const QJsonDocument document = QJsonDocument::fromJson(file.readAll(), &parseError);
if (parseError.error != QJsonParseError::NoError || !document.isObject()) {
if (error)
*error = QObject::tr("Повреждён файл версии %1: %2")
*error = Loc::text("version.error.fileCorrupt")
.arg(QDir::toNativeSeparators(path), parseError.errorString());
return version;
}
@@ -544,7 +545,7 @@ MinecraftVersion VersionLoader::load(const QString &gameDir,
version.clientJarPath = versionJarPath(gameDir, chainIds.constLast());
if (version.mainClass.isEmpty() && error)
*error = QObject::tr("В файле версии «%1» не указан mainClass").arg(versionId);
*error = Loc::text("version.error.noMainClass").arg(versionId);
return version;
}