fix: make local search work in combination with vue-i18n (#3559)

pull/3564/head
Pim Schreurs 11 months ago committed by GitHub
parent fb380e6c38
commit 6624bb7486
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -362,7 +362,7 @@ const defaultTranslations: { modal: ModalTranslations } = {
} }
} }
const $t = createSearchTranslate(defaultTranslations) const translate = createSearchTranslate(defaultTranslations)
// Back // Back
@ -452,7 +452,7 @@ function formMarkRegex(terms: Set<string>) {
<div class="search-actions before"> <div class="search-actions before">
<button <button
class="back-button" class="back-button"
:title="$t('modal.backButtonTitle')" :title="translate('modal.backButtonTitle')"
@click="$emit('close')" @click="$emit('close')"
> >
<svg <svg
@ -486,7 +486,7 @@ function formMarkRegex(terms: Set<string>) {
class="toggle-layout-button" class="toggle-layout-button"
type="button" type="button"
:class="{ 'detailed-list': showDetailedList }" :class="{ 'detailed-list': showDetailedList }"
:title="$t('modal.displayDetails')" :title="translate('modal.displayDetails')"
@click=" @click="
selectedIndex > -1 && (showDetailedList = !showDetailedList) selectedIndex > -1 && (showDetailedList = !showDetailedList)
" "
@ -512,7 +512,7 @@ function formMarkRegex(terms: Set<string>) {
class="clear-button" class="clear-button"
type="reset" type="reset"
:disabled="disableReset" :disabled="disableReset"
:title="$t('modal.resetButtonTitle')" :title="translate('modal.resetButtonTitle')"
@click="resetSearch" @click="resetSearch"
> >
<svg <svg
@ -598,14 +598,14 @@ function formMarkRegex(terms: Set<string>) {
v-if="filterText && !results.length && enableNoResults" v-if="filterText && !results.length && enableNoResults"
class="no-results" class="no-results"
> >
{{ $t('modal.noResultsText') }} "<strong>{{ filterText }}</strong {{ translate('modal.noResultsText') }} "<strong>{{ filterText }}</strong
>" >"
</li> </li>
</ul> </ul>
<div class="search-keyboard-shortcuts"> <div class="search-keyboard-shortcuts">
<span> <span>
<kbd :aria-label="$t('modal.footer.navigateUpKeyAriaLabel')"> <kbd :aria-label="translate('modal.footer.navigateUpKeyAriaLabel')">
<svg width="14" height="14" viewBox="0 0 24 24"> <svg width="14" height="14" viewBox="0 0 24 24">
<path <path
fill="none" fill="none"
@ -617,7 +617,7 @@ function formMarkRegex(terms: Set<string>) {
/> />
</svg> </svg>
</kbd> </kbd>
<kbd :aria-label="$t('modal.footer.navigateDownKeyAriaLabel')"> <kbd :aria-label="translate('modal.footer.navigateDownKeyAriaLabel')">
<svg width="14" height="14" viewBox="0 0 24 24"> <svg width="14" height="14" viewBox="0 0 24 24">
<path <path
fill="none" fill="none"
@ -629,10 +629,10 @@ function formMarkRegex(terms: Set<string>) {
/> />
</svg> </svg>
</kbd> </kbd>
{{ $t('modal.footer.navigateText') }} {{ translate('modal.footer.navigateText') }}
</span> </span>
<span> <span>
<kbd :aria-label="$t('modal.footer.selectKeyAriaLabel')"> <kbd :aria-label="translate('modal.footer.selectKeyAriaLabel')">
<svg width="14" height="14" viewBox="0 0 24 24"> <svg width="14" height="14" viewBox="0 0 24 24">
<g <g
fill="none" fill="none"
@ -646,11 +646,11 @@ function formMarkRegex(terms: Set<string>) {
</g> </g>
</svg> </svg>
</kbd> </kbd>
{{ $t('modal.footer.selectText') }} {{ translate('modal.footer.selectText') }}
</span> </span>
<span> <span>
<kbd :aria-label="$t('modal.footer.closeKeyAriaLabel')">esc</kbd> <kbd :aria-label="translate('modal.footer.closeKeyAriaLabel')">esc</kbd>
{{ $t('modal.footer.closeText') }} {{ translate('modal.footer.closeText') }}
</span> </span>
</div> </div>
</div> </div>

@ -10,11 +10,11 @@ const defaultTranslations: { button: ButtonTranslations } = {
} }
} }
const $t = createSearchTranslate(defaultTranslations) const translate = createSearchTranslate(defaultTranslations)
</script> </script>
<template> <template>
<button type="button" class="DocSearch DocSearch-Button" :aria-label="$t('button.buttonAriaLabel')"> <button type="button" class="DocSearch DocSearch-Button" :aria-label="translate('button.buttonAriaLabel')">
<span class="DocSearch-Button-Container"> <span class="DocSearch-Button-Container">
<svg <svg
class="DocSearch-Search-Icon" class="DocSearch-Search-Icon"
@ -32,7 +32,7 @@ const $t = createSearchTranslate(defaultTranslations)
stroke-linejoin="round" stroke-linejoin="round"
/> />
</svg> </svg>
<span class="DocSearch-Button-Placeholder">{{ $t('button.buttonText') }}</span> <span class="DocSearch-Button-Placeholder">{{ translate('button.buttonText') }}</span>
</span> </span>
<span class="DocSearch-Button-Keys"> <span class="DocSearch-Button-Keys">
<kbd class="DocSearch-Button-Key"></kbd> <kbd class="DocSearch-Button-Key"></kbd>

Loading…
Cancel
Save