diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index ada1f35a..cc738075 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1837,9 +1837,10 @@ languagePackStrings strings:vector = LanguagePackStrings; //@name Language name @native_name Name of the language in that language //@plural_code A language code to be used to apply plural forms. See https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html for more info //@is_official True, if the language pack is official @is_rtl True, if the language pack strings are RTL @is_beta True, if the language pack is a beta language pack +//@is_installed True, if the language pack is installed by the current user //@total_string_count Total number of non-deleted strings from the language pack @translated_string_count Total number of translated strings from the language pack //@local_string_count Total number of non-deleted strings from the language pack available locally @translation_url Link to language translation interface; empty for custom local language packs -languagePackInfo id:string base_language_pack_id:string name:string native_name:string plural_code:string is_official:Bool is_rtl:Bool is_beta:Bool total_string_count:int32 translated_string_count:int32 local_string_count:int32 translation_url:string = LanguagePackInfo; +languagePackInfo id:string base_language_pack_id:string name:string native_name:string plural_code:string is_official:Bool is_rtl:Bool is_beta:Bool is_installed:Bool total_string_count:int32 translated_string_count:int32 local_string_count:int32 translation_url:string = LanguagePackInfo; //@description Contains information about the current localization target @language_packs List of available language packs for this application localizationTargetInfo language_packs:vector = LocalizationTargetInfo; @@ -3410,7 +3411,7 @@ getLanguagePackInfo language_pack_id:string = LanguagePackInfo; //@description Returns strings from a language pack in the current localization target by their keys @language_pack_id Language pack identifier of the strings to be returned @keys Language pack keys of the strings to be returned; leave empty to request all available strings getLanguagePackStrings language_pack_id:string keys:vector = LanguagePackStrings; -//@description Adds a custom server language pack to the current localization target @language_pack_id Identifier of a language pack to be added; may be different from a name that is used in an "https://t.me/setlanguage/" link +//@description Adds a custom server language pack to the list of installed language packs in current localization target @language_pack_id Identifier of a language pack to be added; may be different from a name that is used in an "https://t.me/setlanguage/" link addCustomServerLanguagePack language_pack_id:string = Ok; //@description Adds or changes a custom local language pack to the current localization target @info Information about the language pack. Language pack ID must start with 'X', consist only of English letters, digits and hyphens, and must not exceed 64 characters @strings Strings of the new language pack diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 5f3733f4..be5a80c3 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/LanguagePackManager.cpp b/td/telegram/LanguagePackManager.cpp index 2a66caa3..6943242c 100644 --- a/td/telegram/LanguagePackManager.cpp +++ b/td/telegram/LanguagePackManager.cpp @@ -767,9 +767,10 @@ void LanguagePackManager::search_language_info(string language_code, td_api::object_ptr LanguagePackManager::get_language_pack_info_object( const string &language_code, const LanguageInfo &info) { - return td_api::make_object( - language_code, info.base_language_code_, info.name_, info.native_name_, info.plural_code_, info.is_official_, - info.is_rtl_, info.is_beta_, info.total_string_count_, info.translated_string_count_, 0, info.translation_url_); + return td_api::make_object(language_code, info.base_language_code_, info.name_, + info.native_name_, info.plural_code_, info.is_official_, + info.is_rtl_, info.is_beta_, false, info.total_string_count_, + info.translated_string_count_, 0, info.translation_url_); } string LanguagePackManager::get_language_info_string(const LanguageInfo &info) { @@ -835,9 +836,11 @@ void LanguagePackManager::on_get_languages(vector(); std::unordered_set added_languages; - auto add_language_info = [&results, &added_languages](const string &language_code, const LanguageInfo &info) { + auto add_language_info = [&results, &added_languages](const string &language_code, const LanguageInfo &info, + bool is_installed) { if (added_languages.insert(language_code).second) { results->language_packs_.push_back(get_language_pack_info_object(language_code, info)); + results->language_packs_.back()->is_installed_ = is_installed; } }; @@ -848,11 +851,11 @@ void LanguagePackManager::on_get_languages(vectorsecond.get(); std::lock_guard pack_lock(pack->mutex_); for (auto &info : pack->custom_language_pack_infos_) { - add_language_info(info.first, info.second); + add_language_info(info.first, info.second, true); } if (only_local) { for (auto &info : pack->server_language_pack_infos_) { - add_language_info(info.first, info.second); + add_language_info(info.first, info.second, false); } } } @@ -865,7 +868,7 @@ void LanguagePackManager::on_get_languages(vectorlang_code_, r_info.ok()); + add_language_info(language->lang_code_, r_info.ok(), false); all_server_infos.emplace_back(std::move(language->lang_code_), r_info.move_as_ok()); } @@ -911,6 +914,10 @@ void LanguagePackManager::on_get_language(tl_object_ptrlanguage_packs_.end()) { LanguagePack *pack = pack_it->second.get(); std::lock_guard pack_lock(pack->mutex_); + + result->is_installed_ = pack->custom_language_pack_infos_.count(lang_pack_language->lang_code_) != 0 || + pack->custom_language_pack_infos_.count(language_code) != 0; + bool is_changed = false; for (auto &info : pack->server_language_pack_infos_) { if (info.first == lang_pack_language->lang_code_ || info.first == language_code) { @@ -926,6 +933,8 @@ void LanguagePackManager::on_get_language(tl_object_ptr(language_code, "test", name, native_name, "en", true, true, - true, -1, 5, 3, "abacaba"); + true, true, -1, 5, 3, "abacaba"); } static td_api::object_ptr execute(tl_object_ptr f) { diff --git a/td/telegram/files/FileUploader.cpp b/td/telegram/files/FileUploader.cpp index ec675720..152323e1 100644 --- a/td/telegram/files/FileUploader.cpp +++ b/td/telegram/files/FileUploader.cpp @@ -102,7 +102,7 @@ Result FileUploader::on_update_local_location(const Loca } string path; - int64 local_size = 0; + int64 local_size = -1; bool local_is_ready{false}; FileType file_type{FileType::Temp}; if (location.type() == LocalFileLocation::Type::Empty ||