diff --git a/components/settings/SettingsTranslations.vue b/components/settings/SettingsTranslations.vue
new file mode 100644
index 00000000..729a850b
--- /dev/null
+++ b/components/settings/SettingsTranslations.vue
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+ {{ $t('settings.language.translations.hide_specific') }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/status/StatusTranslation.vue b/components/status/StatusTranslation.vue
index daf00a7e..67f2c84a 100644
--- a/components/status/StatusTranslation.vue
+++ b/components/status/StatusTranslation.vue
@@ -12,7 +12,7 @@ const {
} = useTranslation(status, getLanguageCode())
const preferenceHideTranslation = usePreferences('hideTranslation')
-const showButton = computed(() => !preferenceHideTranslation.value && isTranslationEnabled && status.language !== getLanguageCode())
+const showButton = computed(() => !preferenceHideTranslation.value && isTranslationEnabled)
let translating = $ref(false)
const toggleTranslation = async () => {
diff --git a/composables/masto/translate.ts b/composables/masto/translate.ts
index f87ee314..fc623df2 100644
--- a/composables/masto/translate.ts
+++ b/composables/masto/translate.ts
@@ -8,6 +8,40 @@ export interface TranslationResponse {
}
}
+// @see https://github.com/LibreTranslate/LibreTranslate/tree/main/libretranslate/locales
+export const supportedTranslationCodes = [
+ 'ar',
+ 'az',
+ 'cs',
+ 'da',
+ 'de',
+ 'el',
+ 'en',
+ 'eo',
+ 'es',
+ 'fa',
+ 'fi',
+ 'fr',
+ 'ga',
+ 'he',
+ 'hi',
+ 'hu',
+ 'id',
+ 'it',
+ 'ja',
+ 'ko',
+ 'nl',
+ 'pl',
+ 'pt',
+ 'ru',
+ 'sk',
+ 'sv',
+ 'tr',
+ 'uk',
+ 'vi',
+ 'zh',
+] as const
+
export const getLanguageCode = () => {
let code = 'en'
const getCode = (code: string) => code.replace(/-.*$/, '')
@@ -63,9 +97,16 @@ export function useTranslation(status: mastodon.v1.Status | mastodon.v1.StatusEd
translations.set(status, reactive({ visible: false, text: '', success: false, error: '' }))
const translation = translations.get(status)!
+ const userSettings = useUserSettings()
+
+ const shouldTranslate = 'language' in status && status.language && status.language !== to
+ && supportedTranslationCodes.includes(to as any)
+ && supportedTranslationCodes.includes(status.language as any)
+ && !userSettings.value.disabledTranslationLanguages.includes(status.language)
+ const enabled = /*! !useRuntimeConfig().public.translateApi && */ shouldTranslate
async function toggle() {
- if (!('language' in status))
+ if (!shouldTranslate)
return
if (!translation.text) {
@@ -79,7 +120,7 @@ export function useTranslation(status: mastodon.v1.Status | mastodon.v1.StatusEd
}
return {
- enabled: !!useRuntimeConfig().public.translateApi,
+ enabled,
toggle,
translation,
}
diff --git a/composables/settings/definition.ts b/composables/settings/definition.ts
index 36d0e204..c3940ee1 100644
--- a/composables/settings/definition.ts
+++ b/composables/settings/definition.ts
@@ -26,6 +26,7 @@ export interface UserSettings {
colorMode?: ColorMode
fontSize: FontSize
language: string
+ disabledTranslationLanguages: string[]
zenMode: boolean
themeColors?: ThemeColors
}
@@ -56,6 +57,7 @@ export function getDefaultUserSettings(locales: string[]): UserSettings {
return {
language: getDefaultLanguage(locales),
fontSize: DEFAULT_FONT_SIZE,
+ disabledTranslationLanguages: [],
zenMode: false,
preferences: {},
}
diff --git a/locales/de-DE.json b/locales/de-DE.json
index 569522f5..56474539 100644
--- a/locales/de-DE.json
+++ b/locales/de-DE.json
@@ -270,7 +270,14 @@
},
"language": {
"display_language": "Anzeigesprache",
- "label": "Sprache"
+ "label": "Sprache",
+ "translations": {
+ "add": "Hinzufügen",
+ "choose_language": "Sprache wählen",
+ "heading": "Übersetzungen",
+ "hide_specific": "Bestimmte Übersetzungen ausblenden",
+ "remove": "Entfernen"
+ }
},
"notifications": {
"label": "Benachrichtigungen",
@@ -328,7 +335,7 @@
"hide_boost_count": "Boost-Zähler ausblenden",
"hide_favorite_count": "Favoritenzahl ausblenden",
"hide_follower_count": "Anzahl der Follower ausblenden",
- "hide_translation": "Übersetzungen ausblenden",
+ "hide_translation": "Übersetzungen komplett ausblenden",
"label": "Einstellungen",
"title": "Experimentelle Funktionen",
"user_picker": "Benutzerauswahl",
diff --git a/locales/en.json b/locales/en.json
index 196da4b2..2072472b 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -316,7 +316,14 @@
},
"language": {
"display_language": "Display Language",
- "label": "Language"
+ "label": "Language",
+ "translations": {
+ "add": "Add",
+ "choose_language": "Choose language",
+ "heading": "Translations",
+ "hide_specific": "Hide specific translations",
+ "remove": "Remove"
+ }
},
"notifications": {
"label": "Notifications",
diff --git a/pages/settings/language/index.vue b/pages/settings/language/index.vue
index 52112f3e..10478711 100644
--- a/pages/settings/language/index.vue
+++ b/pages/settings/language/index.vue
@@ -18,6 +18,10 @@ useHeadFixed({
{{ $t('settings.language.display_language') }}
+
+ {{ $t('settings.language.translations.heading') }}
+
+
diff --git a/pages/settings/preferences/index.vue b/pages/settings/preferences/index.vue
index 373cc26b..dde8f452 100644
--- a/pages/settings/preferences/index.vue
+++ b/pages/settings/preferences/index.vue
@@ -39,12 +39,6 @@ const userSettings = useUserSettings()
>
{{ $t('settings.preferences.hide_follower_count') }}
-
- {{ $t('settings.preferences.hide_translation') }}
-