fix(default-theme): remove use of reactify for search i18n

pull/3276/head
Evan You 11 months ago
parent 9f1f04e00a
commit 8687b86e1e

@ -4,7 +4,6 @@ import {
computedAsync,
debouncedWatch,
onKeyStroke,
reactify,
useEventListener,
useLocalStorage,
useScrollLock,
@ -23,7 +22,6 @@ import {
onMounted,
ref,
shallowRef,
toRef,
watch,
watchEffect,
type Ref
@ -32,7 +30,7 @@ import type { ModalTranslations } from '../../../../types/local-search'
import { pathToFile } from '../../app/utils'
import { useData } from '../composables/data'
import { LRUCache } from '../support/lru'
import { createTranslate } from '../support/translation'
import { createSearchTranslate } from '../support/translation'
const emit = defineEmits<{
(e: 'close'): void
@ -361,10 +359,7 @@ const defaultTranslations: { modal: ModalTranslations } = {
}
}
const $t = reactify(createTranslate)(
toRef(() => theme.value.search?.options),
defaultTranslations
)
const $t = createSearchTranslate(defaultTranslations)
// Back

@ -1,11 +1,6 @@
<script lang="ts" setup>
import { reactify } from '@vueuse/core'
import { toRef } from 'vue'
import type { ButtonTranslations } from '../../../../types/local-search'
import { useData } from '../composables/data'
import { createTranslate } from '../support/translation'
const { theme } = useData()
import { createSearchTranslate } from '../support/translation'
// Button-Translations
const defaultTranslations: { button: ButtonTranslations } = {
@ -15,10 +10,7 @@ const defaultTranslations: { button: ButtonTranslations } = {
}
}
const $t = reactify(createTranslate)(
toRef(() => theme.value.search?.options),
defaultTranslations
)
const $t = createSearchTranslate(defaultTranslations)
</script>
<template>

@ -3,14 +3,14 @@ import { useData } from '../composables/data'
/**
* @param themeObject Can be an object with `translations` and `locales` properties
*/
export function createTranslate(
themeObject: any,
export function createSearchTranslate(
defaultTranslations: Record<string, any>
): (key: string) => string {
const { localeIndex } = useData()
const { localeIndex, theme } = useData()
function translate(key: string): string {
const keyPath = key.split('.')
const themeObject = theme.value.search?.options
const isObject = themeObject && typeof themeObject === 'object'
const locales =

Loading…
Cancel
Save