Add LanguagePackInfo.is_installed field.

GitOrigin-RevId: c32c51a4584ab98aae3b15a1f31cfd9bff268a79
This commit is contained in:
levlam 2019-02-23 18:29:04 +03:00
parent 58f63d36d6
commit f32ed5c405
5 changed files with 21 additions and 11 deletions

View File

@ -1837,9 +1837,10 @@ languagePackStrings strings:vector<languagePackString> = 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<languagePackInfo> = 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<string> = 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

Binary file not shown.

View File

@ -767,9 +767,10 @@ void LanguagePackManager::search_language_info(string language_code,
td_api::object_ptr<td_api::languagePackInfo> LanguagePackManager::get_language_pack_info_object(
const string &language_code, const LanguageInfo &info) {
return td_api::make_object<td_api::languagePackInfo>(
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<td_api::languagePackInfo>(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<tl_object_ptr<telegram_api::la
auto results = td_api::make_object<td_api::localizationTargetInfo>();
std::unordered_set<string> 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(vector<tl_object_ptr<telegram_api::la
LanguagePack *pack = pack_it->second.get();
std::lock_guard<std::mutex> 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(vector<tl_object_ptr<telegram_api::la
continue;
}
add_language_info(language->lang_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_ptr<telegram_api::langPackLa
if (pack_it != database_->language_packs_.end()) {
LanguagePack *pack = pack_it->second.get();
std::lock_guard<std::mutex> 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<telegram_api::langPackLa
if (is_changed) {
save_server_language_pack_infos(pack);
}
} else {
LOG(ERROR) << "Failed to find localization target " << language_pack;
}
promise.set_value(std::move(result));

View File

@ -1193,7 +1193,7 @@ class CliClient final : public Actor {
const string &name,
const string &native_name) {
return td_api::make_object<td_api::languagePackInfo>(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<td_api::Object> execute(tl_object_ptr<td_api::Function> f) {

View File

@ -102,7 +102,7 @@ Result<FileLoader::PrefixInfo> 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 ||