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

pull/3276/head
Evan You 2 years ago
parent 9f1f04e00a
commit 8687b86e1e

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

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

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

Loading…
Cancel
Save