From d2bbf41fb55bd53c7d40e54b2663028afd4e2105 Mon Sep 17 00:00:00 2001 From: Yuki Shindo Date: Thu, 12 Dec 2024 01:07:41 +0900 Subject: [PATCH] Add translated setting names to the search index for improved localization support (#1865) * feat: add translated setting names to the search index for improved localization support * nit --------- Co-authored-by: huchenlei --- .../dialog/content/SettingDialogContent.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/dialog/content/SettingDialogContent.vue b/src/components/dialog/content/SettingDialogContent.vue index 60be14410..45cfebe1d 100644 --- a/src/components/dialog/content/SettingDialogContent.vue +++ b/src/components/dialog/content/SettingDialogContent.vue @@ -183,12 +183,21 @@ const handleSearch = (query: string) => { return } + const queryLower = query.toLocaleLowerCase() const allSettings = flattenTree(settingRoot.value) - const filteredSettings = allSettings.filter( - (setting) => - setting.id.toLowerCase().includes(query.toLowerCase()) || - setting.name.toLowerCase().includes(query.toLowerCase()) - ) + const filteredSettings = allSettings.filter((setting) => { + const idLower = setting.id.toLowerCase() + const nameLower = setting.name.toLowerCase() + const translatedName = t( + `settingsDialog.${normalizeI18nKey(setting.id)}.name` + ).toLocaleLowerCase() + + return ( + idLower.includes(queryLower) || + nameLower.includes(queryLower) || + translatedName.includes(queryLower) + ) + }) const groupedSettings: { [key: string]: SettingParams[] } = {} filteredSettings.forEach((setting) => {