Remove legacy langpacks.

This commit is contained in:
John Preston 2019-07-04 14:25:16 +02:00
parent b96b801b22
commit b1807938ad
11 changed files with 5 additions and 8969 deletions

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

View File

@ -68,12 +68,4 @@
<qresource prefix="/misc">
<file alias="default_shortcuts-custom.json">../default_shortcuts-custom.json</file>
</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>

View File

@ -240,23 +240,11 @@ void CloudManager::setSuggestedLanguage(const QString &langCode) {
_languageWasSuggested = true;
_firstLanguageSuggestion.notify();
if (AuthSession::Exists() && _langpack.id().isEmpty() && !_suggestedLanguage.isEmpty()) {
auto isLegacy = [](const QString &languageId) {
for (auto &legacyString : kLegacyLanguages) {
auto legacyId = str_const_toString(legacyString);
if (ConvertLegacyLanguageId(legacyId) == languageId) {
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();
}
if (AuthSession::Exists()
&& _langpack.id().isEmpty()
&& !_suggestedLanguage.isEmpty()) {
_offerSwitchToId = _suggestedLanguage;
offerSwitchLangPack();
}
}
}

View File

@ -294,7 +294,6 @@ void Instance::reset(const Language &data) {
_name = data.name;
_nativeName = data.nativeName;
_legacyId = kLegacyLanguageNone;
_customFilePathAbsolute = QString();
_customFilePathRelative = QString();
_customFileContent = QByteArray();
@ -603,46 +602,6 @@ bool Instance::loadFromCustomFile(const QString &filePath) {
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.
// It is called for all key-value pairs in string.
// ResetCallback takes one QByteArray: key.

View File

@ -13,24 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
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 {
QString id;
QString pluralId;
@ -91,7 +73,6 @@ public:
QByteArray serialize() const;
void fillFromSerialized(const QByteArray &data, int dataAppVersion);
void fillFromLegacy(int legacyId, const QString &legacyPath);
void applyDifference(
Pack pack,
@ -144,7 +125,6 @@ private:
QString _id, _pluralId;
rpl::event_stream<QString> _idChanges;
QString _name, _nativeName;
int _legacyId = kLegacyLanguageNone;
QString _customFilePathAbsolute;
QString _customFilePathRelative;
QByteArray _customFileContent;

View File

@ -841,17 +841,11 @@ void _readLocations() {
}
struct ReadSettingsContext {
int legacyLanguageId = Lang::kLegacyLanguageNone;
QString legacyLanguageFile;
MTP::DcOptions dcOptions;
};
void applyReadContext(ReadSettingsContext &&context) {
Core::App().dcOptions()->addFromOther(std::move(context.dcOptions));
if (context.legacyLanguageId != Lang::kLegacyLanguageNone) {
Lang::Current().fillFromLegacy(context.legacyLanguageId, context.legacyLanguageFile);
writeLangPack();
}
}
QByteArray serializeCallSettings(){
@ -1478,16 +1472,12 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
qint32 v;
stream >> v;
if (!_checkStreamStatus(stream)) return false;
context.legacyLanguageId = v;
} break;
case dbiLangFileOld: {
QString v;
stream >> v;
if (!_checkStreamStatus(stream)) return false;
context.legacyLanguageFile = v;
} break;
case dbiWindowPosition: {