From 4168c64d20c6cce0c71b1a201f990db26a962ee3 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Mon, 17 Jul 2023 20:39:53 +0200 Subject: [PATCH] Add a setting to turn off auto detect language when posting close #1461 --- .../App/Tabs/Settings/TranslationSettingsView.swift | 9 +++++++++ .../Resources/Localization/be.lproj/Localizable.strings | 2 ++ .../Resources/Localization/ca.lproj/Localizable.strings | 2 ++ .../Resources/Localization/de.lproj/Localizable.strings | 2 ++ .../Localization/en-GB.lproj/Localizable.strings | 2 ++ .../Resources/Localization/en.lproj/Localizable.strings | 2 ++ .../Resources/Localization/es.lproj/Localizable.strings | 2 ++ .../Resources/Localization/eu.lproj/Localizable.strings | 2 ++ .../Resources/Localization/fr.lproj/Localizable.strings | 2 ++ .../Resources/Localization/it.lproj/Localizable.strings | 2 ++ .../Resources/Localization/ja.lproj/Localizable.strings | 2 ++ .../Resources/Localization/ko.lproj/Localizable.strings | 2 ++ .../Resources/Localization/nb.lproj/Localizable.strings | 2 ++ .../Resources/Localization/nl.lproj/Localizable.strings | 2 ++ .../Resources/Localization/pl.lproj/Localizable.strings | 2 ++ .../Localization/pt-BR.lproj/Localizable.strings | 2 ++ .../Resources/Localization/tr.lproj/Localizable.strings | 2 ++ .../Resources/Localization/uk.lproj/Localizable.strings | 2 ++ .../Localization/zh-Hans.lproj/Localizable.strings | 2 ++ .../Localization/zh-Hant.lproj/Localizable.strings | 2 ++ Packages/Env/Sources/Env/UserPreferences.swift | 1 + .../Status/Sources/Status/Editor/StatusEditorView.swift | 2 +- 22 files changed, 49 insertions(+), 1 deletion(-) diff --git a/IceCubesApp/App/Tabs/Settings/TranslationSettingsView.swift b/IceCubesApp/App/Tabs/Settings/TranslationSettingsView.swift index a36358b9..a3489830 100644 --- a/IceCubesApp/App/Tabs/Settings/TranslationSettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/TranslationSettingsView.swift @@ -38,6 +38,15 @@ struct TranslationSettingsView: View { .listRowBackground(theme.primaryBackgroundColor) } } + + Section { + Toggle(isOn: preferences.$autoDetectPostLanguage) { + Text("settings.translation.auto-detect-post-language") + } + } footer: { + Text("settings.translation.auto-detect-post-language-footer") + } + } .navigationTitle("settings.translation.navigation-title") .scrollContentBackground(.hidden) diff --git a/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings index af462436..b82e1e1b 100644 --- a/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/be.lproj/Localizable.strings @@ -173,6 +173,8 @@ "settings.general.translate" = "Translation Settings"; "settings.translation.navigation-title" = "Translation"; "settings.translation.always-deepl" = "Always Translate using DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API Key"; "settings.translation.api-key-type" = "Type of the Key"; "settings.translation.needed-message" = "This feature requires a DeepL API key"; diff --git a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings index dc1bffd1..57976319 100644 --- a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings @@ -167,6 +167,8 @@ "settings.general.translate" = "Translation Settings"; "settings.translation.navigation-title" = "Translation"; "settings.translation.always-deepl" = "Always Translate using DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API Key"; "settings.translation.api-key-type" = "Type of the Key"; "settings.translation.needed-message" = "This feature requires a DeepL API key"; diff --git a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings index 1cb1a5d8..58860e61 100644 --- a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings @@ -144,6 +144,8 @@ "settings.general.translate" = "Übersetzungseinstellungen"; "settings.translation.navigation-title" = "Übersetzung"; "settings.translation.always-deepl" = "Immer mit DeepL übersetzen"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL-API-Schlüssel"; "settings.translation.api-key-type" = "Typ des Schlüssels"; "settings.translation.needed-message" = "Für diese Funktion ist ein DeepL-API-Schlüssel erforderlich."; diff --git a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings index 96516c9f..5c55221c 100644 --- a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings @@ -174,6 +174,8 @@ "settings.general.translate" = "Translation Settings"; "settings.translation.navigation-title" = "Translation"; "settings.translation.always-deepl" = "Always Translate using DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API Key"; "settings.translation.api-key-type" = "Type of the Key"; "settings.translation.needed-message" = "This feature requires a DeepL API key"; diff --git a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings index 9d4181ee..6b8516ac 100644 --- a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings @@ -173,6 +173,8 @@ "settings.general.translate" = "Translation Settings"; "settings.translation.navigation-title" = "Translation"; "settings.translation.always-deepl" = "Always Translate using DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API Key"; "settings.translation.api-key-type" = "Type of the Key"; "settings.translation.needed-message" = "This feature requires a DeepL API key"; diff --git a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings index 1a7c6430..e3f93ee5 100644 --- a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings @@ -144,6 +144,8 @@ "settings.general.translate" = "Ajustes de traducción"; "settings.translation.navigation-title" = "Traducción"; "settings.translation.always-deepl" = "Traducir siempre con DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "Clave API de DeepL"; "settings.translation.api-key-type" = "Tipo de clave"; "settings.translation.needed-message" = "Esta funcionalidad requiere una clave API de DeepL"; diff --git a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings index aebb0085..ed10738b 100644 --- a/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/eu.lproj/Localizable.strings @@ -144,6 +144,8 @@ "settings.general.translate" = "Itzulpenaren ezarpenak"; "settings.translation.navigation-title" = "Itzulpenaren ezarpenak"; "settings.translation.always-deepl" = "Itzuli beti DeepL erabiliz"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API gakoa"; "settings.translation.api-key-type" = "Gako mota"; "settings.translation.needed-message" = "Ezaugarri honek DeepL API gako bat behar du"; diff --git a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings index 26ad79ed..cc7d48ab 100644 --- a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings @@ -168,6 +168,8 @@ "settings.general.translate" = "Translation Settings"; "settings.translation.navigation-title" = "Translation"; "settings.translation.always-deepl" = "Always Translate using DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API Key"; "settings.translation.api-key-type" = "Type of the Key"; "settings.translation.needed-message" = "This feature requires a DeepL API key"; diff --git a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings index a60fa73e..5a2e1b24 100644 --- a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings @@ -143,6 +143,8 @@ "settings.general.translate" = "Translation Settings"; "settings.translation.navigation-title" = "Translation"; "settings.translation.always-deepl" = "Always Translate using DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API Key"; "settings.translation.api-key-type" = "Type of the Key"; "settings.translation.needed-message" = "This feature requires a DeepL API key"; diff --git a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings index 0cf73c6a..cdd358ca 100644 --- a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings @@ -173,6 +173,8 @@ "settings.general.translate" = "翻訳設定"; "settings.translation.navigation-title" = "翻訳設定"; "settings.translation.always-deepl" = "DeepLを使用して常に翻訳する"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL APIキー"; "settings.translation.api-key-type" = "キーのタイプ"; "settings.translation.needed-message" = "この機能には DeepL APIキーが必要です"; diff --git a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings index 148c7f8b..1a4e30db 100644 --- a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings @@ -168,6 +168,8 @@ "settings.general.translate" = "번역 설정"; "settings.translation.navigation-title" = "번역 설정"; "settings.translation.always-deepl" = "항상 DeepL을 통해 번역"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API 키"; "settings.translation.api-key-type" = "API 키 종류"; "settings.translation.needed-message" = "이 기능을 사용하려면 DeepL에서 발급받은 API 키가 있어야 합니다."; diff --git a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings index 32ad8567..83652fce 100644 --- a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings @@ -173,6 +173,8 @@ "settings.general.translate" = "Oversettelsesinnstillinger"; "settings.translation.navigation-title" = "Oversettelse"; "settings.translation.always-deepl" = "Oversett alltid med DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API-nøkkel"; "settings.translation.api-key-type" = "Type nøkkel"; "settings.translation.needed-message" = "Denne funksjonen krever en DeepL API-nøkkel"; diff --git a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings index 34523f8f..b3a0509c 100644 --- a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings @@ -144,6 +144,8 @@ "settings.general.translate" = "Vertalingsinstellingen"; "settings.translation.navigation-title" = "Vertaling"; "settings.translation.always-deepl" = "Vertaal altijd met DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API-sleutel"; "settings.translation.api-key-type" = "Sleuteltype"; "settings.translation.needed-message" = "Deze functionaliteit vereist een DeepL API-sleutel"; diff --git a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings index f7f2843e..ea8fb2f2 100644 --- a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings @@ -169,6 +169,8 @@ "settings.general.translate" = "Ustawienia tłumaczenia"; "settings.translation.navigation-title" = "Ustawienia tłumaczenia"; "settings.translation.always-deepl" = "Zawsze tłumacz przy pomocy DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "Klucz DeepL API"; "settings.translation.api-key-type" = "Rodzaj klucza"; "settings.translation.needed-message" = "Ta funkcja wymaga klucza DeepL API"; diff --git a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings index 2b0bf566..d182ba03 100644 --- a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings @@ -168,6 +168,8 @@ "settings.general.translate" = "Ajustes de Tradução"; "settings.translation.navigation-title" = "Tradução"; "settings.translation.always-deepl" = "Sempre traduzir utilizando DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "Chave da API DeepL"; "settings.translation.api-key-type" = "Tipo da chave"; "settings.translation.needed-message" = "Esta funcionalidade requer uma chave de API DeepL"; diff --git a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings index 1ff115a4..0b6edfa0 100644 --- a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings @@ -168,6 +168,8 @@ "settings.general.translate" = "Translation Settings"; "settings.translation.navigation-title" = "Translation"; "settings.translation.always-deepl" = "Always Translate using DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API Key"; "settings.translation.api-key-type" = "Type of the Key"; "settings.translation.needed-message" = "This feature requires a DeepL API key"; diff --git a/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings index 9a8d68f9..890dc6d7 100644 --- a/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/uk.lproj/Localizable.strings @@ -173,6 +173,8 @@ "settings.general.translate" = "Налаштування перекладу"; "settings.translation.navigation-title" = "Переклад"; "settings.translation.always-deepl" = "Завжди перекладати за допомогою DeepL"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API Key"; "settings.translation.api-key-type" = "Тип ключа"; "settings.translation.needed-message" = "Ця функція потребує ключа DeepL API key"; diff --git a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings index d77e2bb2..692cd2eb 100644 --- a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings @@ -144,6 +144,8 @@ "settings.general.translate" = "翻译设置"; "settings.translation.navigation-title" = "翻译设置"; "settings.translation.always-deepl" = "总是使用 DeepL 翻译"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API 密钥"; "settings.translation.api-key-type" = "密钥类型"; "settings.translation.needed-message" = "该功能需要 DeepL API 密钥"; diff --git a/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings index a7fea8a0..f32f0d50 100644 --- a/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hant.lproj/Localizable.strings @@ -217,6 +217,8 @@ "settings.general.translate" = "翻譯設定"; "settings.translation.navigation-title" = "翻譯設定"; "settings.translation.always-deepl" = "一概用 DeepL 翻譯"; +"settings.translation.auto-detect-post-language" = "Auto detect language"; +"settings.translation.auto-detect-post-language-footer" = "Ice Cubes will try to automatically detect the language of the post you're about to post and will suggest to update your post language if necessary."; "settings.translation.user-api-key" = "DeepL API Key"; "settings.translation.api-key-type" = "Key 類型"; "settings.translation.needed-message" = "本功能需有 DeepL API key"; diff --git a/Packages/Env/Sources/Env/UserPreferences.swift b/Packages/Env/Sources/Env/UserPreferences.swift index 18c675fa..9786ad0a 100644 --- a/Packages/Env/Sources/Env/UserPreferences.swift +++ b/Packages/Env/Sources/Env/UserPreferences.swift @@ -28,6 +28,7 @@ public class UserPreferences: ObservableObject { @AppStorage("autoplay_video") public var autoPlayVideo = true @AppStorage("always_use_deepl") public var alwaysUseDeepl = false @AppStorage("user_deepl_api_free") public var userDeeplAPIFree = true + @AppStorage("auto_detect_post_language") public var autoDetectPostLanguage = true @AppStorage("suppress_dupe_reblogs") public var suppressDupeReblogs: Bool = false diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorView.swift b/Packages/Status/Sources/Status/Editor/StatusEditorView.swift index b8b14bd0..06dfad24 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorView.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorView.swift @@ -108,7 +108,7 @@ public struct StatusEditorView: View { Button { Task { viewModel.evaluateLanguages() - if let _ = viewModel.languageConfirmationDialogLanguages { + if preferences.autoDetectPostLanguage, let _ = viewModel.languageConfirmationDialogLanguages { isLanguageConfirmPresented = true } else { await postStatus()