Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing a way for translating Algolia search #77

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion demo/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const path = require('path')
*/
module.exports = (async () => {
const base = await getBase()

return {
...base,

Expand All @@ -25,13 +26,28 @@ module.exports = (async () => {
title: 'Vue.js',
description: 'Vue.js - The Progressive JavaScript Framework',

/**
* @type {import('../../src/vitepress/config').Config}
*/
themeConfig: {
logo: '/img/logo-vue.svg',

algolia: {
indexName: 'vuejs-v3',
appId: 'BH4D9OD16A',
apiKey: 'bc6e8acb44ed4179c30d0a45d6140d3f'
apiKey: 'bc6e8acb44ed4179c30d0a45d6140d3f',
placeholder: 'Search on Vue theme',
translations: {
modal: {
searchBox: {
cancelButtonText: 'Abort',
resetButtonTitle: 'Clear search term'
},
footer: {
searchByText: 'Search gracefully done by '
}
}
}
},

carbonAds: {
Expand Down
49 changes: 49 additions & 0 deletions src/vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,55 @@ export interface AlgoliaSearchOptions {
searchParameters?: any
disableUserPersonalization?: boolean
initialQuery?: string
translations?: Partial<DocSearchTranslations>
}

export interface DocSearchTranslations {
button?: ButtonTranslations
modal?: ModalTranslations
}

export interface ButtonTranslations {
buttonText?: string
buttonAriaLabel?: string
}
export interface ModalTranslations extends ScreenStateTranslations {
searchBox?: {
resetButtonTitle?: string
resetButtonAriaLabel?: string
cancelButtonText?: string
cancelButtonAriaLabel?: string
}
footer?: {
selectText?: string
selectKeyAriaLabel?: string
navigateText?: string
navigateUpKeyAriaLabel?: string
navigateDownKeyAriaLabel?: string
closeText?: string
closeKeyAriaLabel?: string
searchByText?: string
}
}
export interface ScreenStateTranslations {
errorScreen?: {
titleText?: string
helpText?: string
}
startScreen?: {
recentSearchesTitle?: string
noRecentSearchesText?: string
saveRecentSearchButtonTitle?: string
removeRecentSearchButtonTitle?: string
favoriteSearchesTitle?: string
removeFavoriteSearchButtonTitle?: string
}
noResultsScreen?: {
noResultsText?: string
suggestedQueryText?: string
reportMissingResultsText?: string
reportMissingResultsLinkText?: string
}
}

export type NavItem = NavItemWithLink | NavItemWithChildren
Expand Down