Skip to content

Commit

Permalink
fix(default-theme): remove use of reactify for search i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 27, 2023
1 parent 9f1f04e commit 8687b86
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
9 changes: 2 additions & 7 deletions src/client/theme-default/components/VPLocalSearchBox.vue
Expand Up @@ -4,7 +4,6 @@ import {
computedAsync,
debouncedWatch,
onKeyStroke,
reactify,
useEventListener,
useLocalStorage,
useScrollLock,
Expand All @@ -23,7 +22,6 @@ import {
onMounted,
ref,
shallowRef,
toRef,
watch,
watchEffect,
type Ref
Expand All @@ -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
Expand Down Expand Up @@ -361,10 +359,7 @@ const defaultTranslations: { modal: ModalTranslations } = {
}
}
const $t = reactify(createTranslate)(
toRef(() => theme.value.search?.options),
defaultTranslations
)
const $t = createSearchTranslate(defaultTranslations)
// Back
Expand Down
12 changes: 2 additions & 10 deletions src/client/theme-default/components/VPNavBarSearchButton.vue
@@ -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 } = {
Expand All @@ -15,10 +10,7 @@ const defaultTranslations: { button: ButtonTranslations } = {
}
}
const $t = reactify(createTranslate)(
toRef(() => theme.value.search?.options),
defaultTranslations
)
const $t = createSearchTranslate(defaultTranslations)
</script>

<template>
Expand Down
6 changes: 3 additions & 3 deletions src/client/theme-default/support/translation.ts
Expand Up @@ -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 =
Expand Down

0 comments on commit 8687b86

Please sign in to comment.