feat(settings): make Language setting findable by native-language search terms (#9967)
The Language setting's native word (语言 / 언어 / 言語 / Idioma) only reached settings search via the localized title in that word's own UI locale — so a Chinese speaker on the default English UI could not find it by typing 语言. Always-index the native word for 'language' in every supported language (plus the previously-omitted Spanish native name Español), so speakers can locate and switch to their language from any starting locale. Native words are locale-invariant constants, so they are plain keyword literals with reviewed localization-coverage allowlist entries. Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
parent
dfbc2e8ba7
commit
4c2bb508c3
|
|
@ -5,5 +5,40 @@
|
|||
"text": "Terminal 1",
|
||||
"dynamic": false,
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"filePath": "src/renderer/src/components/settings/appearance-search.ts",
|
||||
"kind": "object-property:keywords",
|
||||
"text": "语言",
|
||||
"dynamic": false,
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"filePath": "src/renderer/src/components/settings/appearance-search.ts",
|
||||
"kind": "object-property:keywords",
|
||||
"text": "語言",
|
||||
"dynamic": false,
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"filePath": "src/renderer/src/components/settings/appearance-search.ts",
|
||||
"kind": "object-property:keywords",
|
||||
"text": "언어",
|
||||
"dynamic": false,
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"filePath": "src/renderer/src/components/settings/appearance-search.ts",
|
||||
"kind": "object-property:keywords",
|
||||
"text": "言語",
|
||||
"dynamic": false,
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"filePath": "src/renderer/src/components/settings/appearance-search.ts",
|
||||
"kind": "object-property:keywords",
|
||||
"text": "Idioma",
|
||||
"dynamic": false,
|
||||
"count": 1
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
|
||||
import { i18n } from '@/i18n/i18n'
|
||||
import { getLanguageEntries } from './appearance-search'
|
||||
import { matchesSettingsSearch } from './settings-search'
|
||||
|
||||
// Native word for "language" in each supported UI language. These must be
|
||||
// findable no matter which locale the interface is currently rendered in, so a
|
||||
// speaker can locate (and switch to) their language from any starting point.
|
||||
const NATIVE_LANGUAGE_WORDS = ['语言', '語言', '언어', '言語', 'Idioma']
|
||||
|
||||
describe('getLanguageEntries', () => {
|
||||
afterEach(async () => {
|
||||
await i18n.changeLanguage('en')
|
||||
})
|
||||
|
||||
it.each(['en', 'zh', 'ko', 'ja', 'es'])(
|
||||
'indexes every native word for "language" under the %s UI locale',
|
||||
async (locale) => {
|
||||
await i18n.changeLanguage(locale)
|
||||
const entry = getLanguageEntries()[0]
|
||||
for (const word of NATIVE_LANGUAGE_WORDS) {
|
||||
expect(matchesSettingsSearch(word, entry)).toBe(true)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
it('matches the Spanish native language name in English UI', async () => {
|
||||
await i18n.changeLanguage('en')
|
||||
expect(matchesSettingsSearch('Español', getLanguageEntries()[0])).toBe(true)
|
||||
})
|
||||
})
|
||||
|
|
@ -49,6 +49,15 @@ export const getLanguageEntries = createLocalizedCatalog((): SettingsSearchEntry
|
|||
...translateSearchKeyword('settings.appearance.language.chinese', '中文(简体)'),
|
||||
...translateSearchKeyword('settings.appearance.language.korean', '한국어'),
|
||||
...translateSearchKeyword('settings.appearance.language.japanese', '日本語'),
|
||||
...translateSearchKeyword('settings.appearance.language.spanish', 'Español'),
|
||||
// Why: the native word for "language" only reaches search via the localized
|
||||
// title in its own UI locale — index each here so speakers can find (and
|
||||
// switch to) their language whatever the current interface locale is.
|
||||
'语言', // Chinese (Simplified)
|
||||
'語言', // Chinese (Traditional)
|
||||
'언어', // Korean
|
||||
'言語', // Japanese
|
||||
'Idioma', // Spanish
|
||||
...translateSearchKeyword(
|
||||
'auto.components.settings.appearance.search.language.locale',
|
||||
'locale'
|
||||
|
|
|
|||
Loading…
Reference in New Issue