mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Translation improvements
This commit is contained in:
@@ -173,9 +173,17 @@ final class ChatTranslationPanelNode: ASDisplayNode {
|
|||||||
if languageCode.hasSuffix(rawSuffix) {
|
if languageCode.hasSuffix(rawSuffix) {
|
||||||
languageCode = String(languageCode.dropLast(rawSuffix.count))
|
languageCode = String(languageCode.dropLast(rawSuffix.count))
|
||||||
}
|
}
|
||||||
let locale = Locale(identifier: languageCode)
|
|
||||||
let fromLanguage: String = locale.localizedString(forLanguageCode: translationState.fromLang) ?? ""
|
let fromLang = translationState.fromLang
|
||||||
|
let key = "Translation.Language.\(fromLang)"
|
||||||
|
let fromLanguage: String
|
||||||
|
if let string = presentationData.strings.primaryComponent.dict[key] {
|
||||||
|
fromLanguage = string
|
||||||
|
} else {
|
||||||
|
let languageLocale = Locale(identifier: languageCode)
|
||||||
|
fromLanguage = languageLocale.localizedString(forLanguageCode: fromLang) ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
var items: [ContextMenuItem] = []
|
var items: [ContextMenuItem] = []
|
||||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_Translation_ChooseLanguage, icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_Translation_ChooseLanguage, icon: { theme in
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Translate"), color: theme.contextMenu.primaryColor)
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Translate"), color: theme.contextMenu.primaryColor)
|
||||||
@@ -204,24 +212,16 @@ final class ChatTranslationPanelNode: ASDisplayNode {
|
|||||||
topLanguages.append(contentsOf: popularTranslationLanguages)
|
topLanguages.append(contentsOf: popularTranslationLanguages)
|
||||||
|
|
||||||
for code in topLanguages {
|
for code in topLanguages {
|
||||||
if !addedLanguages.contains(code) {
|
if !addedLanguages.contains(code), let title = enLocale.localizedString(forLanguageCode: code) {
|
||||||
let key = "Translation.Language.\(code)"
|
let languageLocale = Locale(identifier: code)
|
||||||
var title: String?
|
let subtitle = languageLocale.localizedString(forLanguageCode: code) ?? title
|
||||||
if let string = presentationData.strings.primaryComponent.dict[key] {
|
let value = (code, subtitle.capitalized)
|
||||||
title = string
|
if code == languageCode {
|
||||||
} else if let engTitle = enLocale.localizedString(forLanguageCode: code) {
|
languages.insert(value, at: 0)
|
||||||
let languageLocale = Locale(identifier: code)
|
} else {
|
||||||
title = languageLocale.localizedString(forLanguageCode: code) ?? engTitle
|
languages.append(value)
|
||||||
}
|
|
||||||
if let title {
|
|
||||||
let value = (code, title.capitalized)
|
|
||||||
if code == languageCode {
|
|
||||||
languages.insert(value, at: 0)
|
|
||||||
} else {
|
|
||||||
languages.append(value)
|
|
||||||
}
|
|
||||||
addedLanguages.insert(code)
|
|
||||||
}
|
}
|
||||||
|
addedLanguages.insert(code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user