parent
							
								
									23c2ae49c6
								
							
						
					
					
						commit
						a11fb2816b
					
				
					 1 changed files with 31 additions and 20 deletions
				
			
		|  | @ -220,26 +220,28 @@ void CloudManager::switchToLanguage(QString id) { | ||||||
| 		QVector<MTPstring> keys; | 		QVector<MTPstring> keys; | ||||||
| 		keys.reserve(3); | 		keys.reserve(3); | ||||||
| 		keys.push_back(MTP_string("lng_sure_save_language")); | 		keys.push_back(MTP_string("lng_sure_save_language")); | ||||||
| 		keys.push_back(MTP_string("lng_box_ok")); |  | ||||||
| 		keys.push_back(MTP_string("lng_cancel")); |  | ||||||
| 		_switchingToLanguageRequest = request(MTPlangpack_GetStrings( | 		_switchingToLanguageRequest = request(MTPlangpack_GetStrings( | ||||||
| 			MTP_string(Lang::CloudLangPackName()), | 			MTP_string(Lang::CloudLangPackName()), | ||||||
| 			MTP_string(id), | 			MTP_string(id), | ||||||
| 			MTP_vector<MTPstring>(std::move(keys)) | 			MTP_vector<MTPstring>(std::move(keys)) | ||||||
| 		)).done([=](const MTPVector<MTPLangPackString> &result) { | 		)).done([=](const MTPVector<MTPLangPackString> &result) { | ||||||
| 			auto values = Instance::ParseStrings(result); | 			const auto values = Instance::ParseStrings(result); | ||||||
| 			auto getValue = [&values](LangKey key) { | 			const auto getValue = [&](LangKey key) { | ||||||
| 				auto it = values.find(key); | 				auto it = values.find(key); | ||||||
| 				return (it == values.cend()) | 				return (it == values.cend()) | ||||||
| 					? GetOriginalValue(key) | 					? GetOriginalValue(key) | ||||||
| 					: it->second; | 					: it->second; | ||||||
| 			}; | 			}; | ||||||
| 			auto text = getValue(lng_sure_save_language); | 			const auto text = lang(lng_sure_save_language) | ||||||
| 			auto save = getValue(lng_box_ok); | 				+ "\n\n" | ||||||
| 			auto cancel = getValue(lng_cancel); | 				+ getValue(lng_sure_save_language); | ||||||
| 			Ui::show(Box<ConfirmBox>(text, save, cancel, [this, id] { | 			Ui::show( | ||||||
| 				performSwitchAndRestart(id); | 				Box<ConfirmBox>( | ||||||
| 			}), LayerOption::KeepOther); | 					text, | ||||||
|  | 					lang(lng_box_ok), | ||||||
|  | 					lang(lng_cancel), | ||||||
|  | 					[=] { performSwitchAndRestart(id); }), | ||||||
|  | 				LayerOption::KeepOther); | ||||||
| 		}).send(); | 		}).send(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | @ -253,24 +255,33 @@ void CloudManager::performSwitchToCustom() { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		auto filePath = result.paths.front(); | 		auto filePath = result.paths.front(); | ||||||
| 		Lang::FileParser loader(filePath, { lng_sure_save_language, lng_box_ok, lng_cancel }); | 		Lang::FileParser loader(filePath, { lng_sure_save_language }); | ||||||
| 		if (loader.errors().isEmpty()) { | 		if (loader.errors().isEmpty()) { | ||||||
| 			weak->request(weak->_switchingToLanguageRequest).cancel(); | 			weak->request(weak->_switchingToLanguageRequest).cancel(); | ||||||
| 			if (weak->canApplyWithoutRestart(qsl("custom"))) { | 			if (weak->canApplyWithoutRestart(qsl("custom"))) { | ||||||
| 				weak->_langpack.switchToCustomFile(filePath); | 				weak->_langpack.switchToCustomFile(filePath); | ||||||
| 			} else { | 			} else { | ||||||
| 				auto values = loader.found(); | 				const auto values = loader.found(); | ||||||
| 				auto getValue = [&values](LangKey key) { | 				const auto getValue = [&](LangKey key) { | ||||||
| 					auto it = values.find(key); | 					const auto it = values.find(key); | ||||||
| 					return (it == values.cend()) ? GetOriginalValue(key) : it.value(); | 					return (it == values.cend()) | ||||||
|  | 						? GetOriginalValue(key) | ||||||
|  | 						: it.value(); | ||||||
| 				}; | 				}; | ||||||
| 				auto text = getValue(lng_sure_save_language); | 				const auto text = lang(lng_sure_save_language) | ||||||
| 				auto save = getValue(lng_box_ok); | 					+ "\n\n" | ||||||
| 				auto cancel = getValue(lng_cancel); | 					 + getValue(lng_sure_save_language); | ||||||
| 				Ui::show(Box<ConfirmBox>(text, save, cancel, [weak, filePath] { | 				const auto change = [=] { | ||||||
| 					weak->_langpack.switchToCustomFile(filePath); | 					weak->_langpack.switchToCustomFile(filePath); | ||||||
| 					App::restart(); | 					App::restart(); | ||||||
| 				}), LayerOption::KeepOther); | 				}; | ||||||
|  | 				Ui::show( | ||||||
|  | 					Box<ConfirmBox>( | ||||||
|  | 						text, | ||||||
|  | 						lang(lng_box_ok), | ||||||
|  | 						lang(lng_cancel), | ||||||
|  | 						change), | ||||||
|  | 					LayerOption::KeepOther); | ||||||
| 			} | 			} | ||||||
| 		} else { | 		} else { | ||||||
| 			Ui::show( | 			Ui::show( | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 John Preston
						John Preston