generated from Seekra/repository-template
Add translations for the color scheme button
This commit is contained in:
@@ -16,6 +16,9 @@ limitations under the License.
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { inject } from 'vue';
|
import { inject } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
const colorScheme = inject('colorScheme');
|
const colorScheme = inject('colorScheme');
|
||||||
|
|
||||||
@@ -25,24 +28,22 @@ const colorSchemeNextMapper = {
|
|||||||
'auto': 'light'
|
'auto': 'light'
|
||||||
};
|
};
|
||||||
|
|
||||||
const colorSchemeTextMapper = {
|
|
||||||
'light': 'Switch to light mode',
|
|
||||||
'dark': 'Switch to dark mode',
|
|
||||||
'auto': 'Switch to the system scheme'
|
|
||||||
}
|
|
||||||
|
|
||||||
const colorSchemeIconMapper = {
|
const colorSchemeIconMapper = {
|
||||||
'dark': '⏾',
|
'dark': '⏾',
|
||||||
'light': '☀',
|
'light': '☀',
|
||||||
'auto': '◐'
|
'auto': '◐'
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const getTooltipTranslation = function (colorScheme) {
|
||||||
|
return t(`preferences.colorScheme.switch.${colorSchemeNextMapper[colorScheme]}`);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<button class="color-scheme-button"
|
<button class="color-scheme-button"
|
||||||
@click="colorScheme = colorSchemeNextMapper[colorScheme]"
|
@click="colorScheme = colorSchemeNextMapper[colorScheme]"
|
||||||
:aria-label="colorSchemeTextMapper[colorSchemeNextMapper[colorScheme]]"
|
:aria-label="getTooltipTranslation(colorScheme)"
|
||||||
:title="colorSchemeTextMapper[colorSchemeNextMapper[colorScheme]]"
|
:title="getTooltipTranslation(colorScheme)"
|
||||||
>
|
>
|
||||||
{{ colorSchemeIconMapper[colorSchemeNextMapper[colorScheme]] }}
|
{{ colorSchemeIconMapper[colorSchemeNextMapper[colorScheme]] }}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -16,5 +16,14 @@
|
|||||||
"back": {
|
"back": {
|
||||||
"search": "Back to Search"
|
"search": "Back to Search"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"preferences": {
|
||||||
|
"colorScheme": {
|
||||||
|
"switch": {
|
||||||
|
"light": "Switch to light mode",
|
||||||
|
"dark": "Switch to dark mode",
|
||||||
|
"auto": "Switch to the system color scheme"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user