mirror of https://github.com/procxx/kepka.git
Remove legacy langpacks.
This commit is contained in:
parent
b96b801b22
commit
b1807938ad
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -68,12 +68,4 @@
|
||||||
<qresource prefix="/misc">
|
<qresource prefix="/misc">
|
||||||
<file alias="default_shortcuts-custom.json">../default_shortcuts-custom.json</file>
|
<file alias="default_shortcuts-custom.json">../default_shortcuts-custom.json</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/langs">
|
|
||||||
<file alias="lang_it.strings">../langs/lang_it.strings</file>
|
|
||||||
<file alias="lang_es.strings">../langs/lang_es.strings</file>
|
|
||||||
<file alias="lang_de.strings">../langs/lang_de.strings</file>
|
|
||||||
<file alias="lang_nl.strings">../langs/lang_nl.strings</file>
|
|
||||||
<file alias="lang_pt_BR.strings">../langs/lang_pt_BR.strings</file>
|
|
||||||
<file alias="lang_ko.strings">../langs/lang_ko.strings</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -240,23 +240,11 @@ void CloudManager::setSuggestedLanguage(const QString &langCode) {
|
||||||
_languageWasSuggested = true;
|
_languageWasSuggested = true;
|
||||||
_firstLanguageSuggestion.notify();
|
_firstLanguageSuggestion.notify();
|
||||||
|
|
||||||
if (AuthSession::Exists() && _langpack.id().isEmpty() && !_suggestedLanguage.isEmpty()) {
|
if (AuthSession::Exists()
|
||||||
auto isLegacy = [](const QString &languageId) {
|
&& _langpack.id().isEmpty()
|
||||||
for (auto &legacyString : kLegacyLanguages) {
|
&& !_suggestedLanguage.isEmpty()) {
|
||||||
auto legacyId = str_const_toString(legacyString);
|
_offerSwitchToId = _suggestedLanguage;
|
||||||
if (ConvertLegacyLanguageId(legacyId) == languageId) {
|
offerSwitchLangPack();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// The old available languages (de/it/nl/ko/es/pt_BR) won't be
|
|
||||||
// suggested anyway, because everyone saw the suggestion in intro.
|
|
||||||
if (!isLegacy(_suggestedLanguage)) {
|
|
||||||
_offerSwitchToId = _suggestedLanguage;
|
|
||||||
offerSwitchLangPack();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,7 +294,6 @@ void Instance::reset(const Language &data) {
|
||||||
_name = data.name;
|
_name = data.name;
|
||||||
_nativeName = data.nativeName;
|
_nativeName = data.nativeName;
|
||||||
|
|
||||||
_legacyId = kLegacyLanguageNone;
|
|
||||||
_customFilePathAbsolute = QString();
|
_customFilePathAbsolute = QString();
|
||||||
_customFilePathRelative = QString();
|
_customFilePathRelative = QString();
|
||||||
_customFileContent = QByteArray();
|
_customFileContent = QByteArray();
|
||||||
|
@ -603,46 +602,6 @@ bool Instance::loadFromCustomFile(const QString &filePath) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::fillFromLegacy(int legacyId, const QString &legacyPath) {
|
|
||||||
if (legacyId == kLegacyDefaultLanguage) {
|
|
||||||
_legacyId = legacyId;
|
|
||||||
|
|
||||||
// We suppose that user didn't switch to the default language,
|
|
||||||
// so we will suggest him to switch to his language if we get it.
|
|
||||||
//
|
|
||||||
// The old available languages (de/it/nl/ko/es/pt_BR) won't be
|
|
||||||
// suggested anyway, because everyone saw the suggestion in intro.
|
|
||||||
_id = QString();// str_const_toString(kLegacyLanguages[legacyId]);
|
|
||||||
} else if (legacyId == kLegacyCustomLanguage) {
|
|
||||||
auto absolutePath = QFileInfo(legacyPath).absoluteFilePath();
|
|
||||||
auto relativePath = QDir().relativeFilePath(absolutePath);
|
|
||||||
auto content = Lang::FileParser::ReadFile(absolutePath, relativePath);
|
|
||||||
if (!content.isEmpty()) {
|
|
||||||
_legacyId = legacyId;
|
|
||||||
fillFromCustomContent(absolutePath, relativePath, content);
|
|
||||||
}
|
|
||||||
} else if (legacyId > kLegacyDefaultLanguage && legacyId < base::array_size(kLegacyLanguages)) {
|
|
||||||
auto languageId = str_const_toString(kLegacyLanguages[legacyId]);
|
|
||||||
auto resourcePath = qsl(":/langs/lang_") + languageId + qsl(".strings");
|
|
||||||
auto content = Lang::FileParser::ReadFile(resourcePath, resourcePath);
|
|
||||||
if (!content.isEmpty()) {
|
|
||||||
_legacyId = legacyId;
|
|
||||||
_id = languageId;
|
|
||||||
_version = 0;
|
|
||||||
loadFromContent(content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_id = LanguageIdOrDefault(ConvertLegacyLanguageId(_id));
|
|
||||||
if (!isCustom()) {
|
|
||||||
_pluralId = _id;
|
|
||||||
}
|
|
||||||
_name = _nativeName = QString();
|
|
||||||
_base = nullptr;
|
|
||||||
updatePluralRules();
|
|
||||||
|
|
||||||
_idChanges.fire_copy(_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetCallback takes two QByteArrays: key, value.
|
// SetCallback takes two QByteArrays: key, value.
|
||||||
// It is called for all key-value pairs in string.
|
// It is called for all key-value pairs in string.
|
||||||
// ResetCallback takes one QByteArray: key.
|
// ResetCallback takes one QByteArray: key.
|
||||||
|
|
|
@ -13,24 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Lang {
|
namespace Lang {
|
||||||
|
|
||||||
constexpr auto kLegacyLanguageNone = -2;
|
|
||||||
constexpr auto kLegacyCustomLanguage = -1;
|
|
||||||
constexpr auto kLegacyDefaultLanguage = 0;
|
|
||||||
|
|
||||||
constexpr str_const kLegacyLanguages[] = {
|
|
||||||
"en",
|
|
||||||
"it",
|
|
||||||
"es",
|
|
||||||
"de",
|
|
||||||
"nl",
|
|
||||||
"pt_BR",
|
|
||||||
"ko",
|
|
||||||
};
|
|
||||||
|
|
||||||
inline QString ConvertLegacyLanguageId(const QString &languageId) {
|
|
||||||
return languageId.toLower().replace('_', '-');
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Language {
|
struct Language {
|
||||||
QString id;
|
QString id;
|
||||||
QString pluralId;
|
QString pluralId;
|
||||||
|
@ -91,7 +73,6 @@ public:
|
||||||
|
|
||||||
QByteArray serialize() const;
|
QByteArray serialize() const;
|
||||||
void fillFromSerialized(const QByteArray &data, int dataAppVersion);
|
void fillFromSerialized(const QByteArray &data, int dataAppVersion);
|
||||||
void fillFromLegacy(int legacyId, const QString &legacyPath);
|
|
||||||
|
|
||||||
void applyDifference(
|
void applyDifference(
|
||||||
Pack pack,
|
Pack pack,
|
||||||
|
@ -144,7 +125,6 @@ private:
|
||||||
QString _id, _pluralId;
|
QString _id, _pluralId;
|
||||||
rpl::event_stream<QString> _idChanges;
|
rpl::event_stream<QString> _idChanges;
|
||||||
QString _name, _nativeName;
|
QString _name, _nativeName;
|
||||||
int _legacyId = kLegacyLanguageNone;
|
|
||||||
QString _customFilePathAbsolute;
|
QString _customFilePathAbsolute;
|
||||||
QString _customFilePathRelative;
|
QString _customFilePathRelative;
|
||||||
QByteArray _customFileContent;
|
QByteArray _customFileContent;
|
||||||
|
|
|
@ -841,17 +841,11 @@ void _readLocations() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ReadSettingsContext {
|
struct ReadSettingsContext {
|
||||||
int legacyLanguageId = Lang::kLegacyLanguageNone;
|
|
||||||
QString legacyLanguageFile;
|
|
||||||
MTP::DcOptions dcOptions;
|
MTP::DcOptions dcOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
void applyReadContext(ReadSettingsContext &&context) {
|
void applyReadContext(ReadSettingsContext &&context) {
|
||||||
Core::App().dcOptions()->addFromOther(std::move(context.dcOptions));
|
Core::App().dcOptions()->addFromOther(std::move(context.dcOptions));
|
||||||
if (context.legacyLanguageId != Lang::kLegacyLanguageNone) {
|
|
||||||
Lang::Current().fillFromLegacy(context.legacyLanguageId, context.legacyLanguageFile);
|
|
||||||
writeLangPack();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray serializeCallSettings(){
|
QByteArray serializeCallSettings(){
|
||||||
|
@ -1478,16 +1472,12 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
|
||||||
qint32 v;
|
qint32 v;
|
||||||
stream >> v;
|
stream >> v;
|
||||||
if (!_checkStreamStatus(stream)) return false;
|
if (!_checkStreamStatus(stream)) return false;
|
||||||
|
|
||||||
context.legacyLanguageId = v;
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiLangFileOld: {
|
case dbiLangFileOld: {
|
||||||
QString v;
|
QString v;
|
||||||
stream >> v;
|
stream >> v;
|
||||||
if (!_checkStreamStatus(stream)) return false;
|
if (!_checkStreamStatus(stream)) return false;
|
||||||
|
|
||||||
context.legacyLanguageFile = v;
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiWindowPosition: {
|
case dbiWindowPosition: {
|
||||||
|
|
Loading…
Reference in New Issue