Skip to content

Commit

Permalink
feat: add user preference to hide translation button (#1358)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaswolf authored Jan 21, 2023
1 parent 5d94eab commit 801b8fe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/status/StatusTranslation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const {
translation,
enabled: isTranslationEnabled,
} = useTranslation(status, getLanguageCode())
const preferenceHideTranslation = usePreferences('hideTranslation')
const showButton = computed(() => !preferenceHideTranslation.value && isTranslationEnabled && status.language !== getLanguageCode())
let translating = $ref(false)
const toggleTranslation = async () => {
Expand All @@ -26,7 +29,7 @@ const toggleTranslation = async () => {
<template>
<div>
<button
v-if="isTranslationEnabled && status.language !== getLanguageCode()" p-0 flex="~ center" gap-2 text-sm
v-if="showButton" p-0 flex="~ center" gap-2 text-sm
:disabled="translating" disabled-bg-transparent btn-text class="disabled-text-$c-text-btn-disabled-deeper" @click="toggleTranslation"
>
<span v-if="translating" block animate-spin preserve-3d>
Expand Down
2 changes: 2 additions & 0 deletions composables/settings/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface PreferencesSettings {
hideBoostCount: boolean
hideFavoriteCount: boolean
hideFollowerCount: boolean
hideTranslation: boolean
grayscaleMode: boolean
enableAutoplay: boolean
experimentalVirtualScroller: boolean
Expand Down Expand Up @@ -58,6 +59,7 @@ export const DEFAULT__PREFERENCES_SETTINGS: PreferencesSettings = {
hideBoostCount: false,
hideFavoriteCount: false,
hideFollowerCount: false,
hideTranslation: false,
grayscaleMode: false,
enableAutoplay: true,
experimentalVirtualScroller: true,
Expand Down
1 change: 1 addition & 0 deletions locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +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",
"label": "Einstellungen",
"title": "Experimentelle Funktionen",
"user_picker": "Benutzerauswahl",
Expand Down
1 change: 1 addition & 0 deletions locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
"hide_boost_count": "Hide boost count",
"hide_favorite_count": "Hide favorite count",
"hide_follower_count": "Hide follower count",
"hide_translation": "Hide translation",
"label": "Preferences",
"title": "Experimental Features",
"user_picker": "User Picker",
Expand Down
6 changes: 6 additions & 0 deletions pages/settings/preferences/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const userSettings = useUserSettings()
>
{{ $t('settings.preferences.hide_follower_count') }}
</SettingsToggleItem>
<SettingsToggleItem
:checked="getPreferences(userSettings, 'hideTranslation')"
@click="togglePreferences('hideTranslation')"
>
{{ $t('settings.preferences.hide_translation') }}
</SettingsToggleItem>
<SettingsToggleItem
:checked="getPreferences(userSettings, 'grayscaleMode')"
@click="togglePreferences('grayscaleMode')"
Expand Down

0 comments on commit 801b8fe

Please sign in to comment.