Skip to content

Commit

Permalink
Do not try to detect "from" language if languageDetection is not supp…
Browse files Browse the repository at this point in the history
…orted.

Signed-off-by: Ivan Sein <[email protected]>
  • Loading branch information
Ivansss committed Oct 10, 2023
1 parent 8ea943c commit 3401297
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion NextcloudTalk/MessageTranslationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ import UIKit
NCAPIController.sharedInstance().getAvailableTranslations(for: activeAccount) { languages, languageDetection, error, _ in
if let translations = languages as? [NCTranslation], error == nil {
self.availableTranslations = translations
self.translateOriginalText(from: "", to: self.userLanguageCode ?? "")
if languageDetection {
self.translateOriginalText(from: "", to: self.userLanguageCode ?? "")
} else {
self.configureFromButton(title: nil, enabled: true)
self.configureToButton(title: nil, enabled: false, fromLanguageCode: "")
self.removeTranslatingUI()
}
} else {
self.showTranslationError(message: NSLocalizedString("Could not get available languages", comment: ""))
self.removeTranslatingUI()
Expand Down Expand Up @@ -214,6 +220,7 @@ import UIKit
// MARK: - Translate

func translateOriginalText(from: String, to: String) {
self.setTranslatingUI()
NCAPIController.sharedInstance().translateMessage(originalMessage, from: from, to: to, for: activeAccount) { responseDict, error, _ in
self.removeTranslatingUI()

Expand Down

0 comments on commit 3401297

Please sign in to comment.