Skip to content

Commit acbf44a

Browse files
committed
♻️ refactor: Refactor i18n of sidebar
Signed-off-by: sqrtthree <[email protected]>
1 parent a42f089 commit acbf44a

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

utils.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,14 @@ export function resolveSidebarItems($page, $site, $localePath) {
7575
let languageSelectText
7676

7777
if ($site.locales) {
78-
let localeTheme = {};
79-
80-
if (themeConfig.locales) {
81-
localeTheme = themeConfig.locales[$localePath]
82-
}
83-
84-
languageSelectText = localeTheme.selectText || 'languages'
78+
languageSelectText = config.get($site, 'selectText', $localePath) || 'languages'
8579

8680
sidebars[languageSelectText] = {
8781
title: languageSelectText,
8882
children: Object.keys($site.locales).map(locale => {
8983
const item = $site.locales[locale]
84+
let languageTitle = config.get($site, 'label', locale) || item.text || item.lang
9085
let path
91-
let languageTitle = item.text || item.lang
9286

9387
if (item.path === $localePath) {
9488
path = $page.path // Stay on the current page
@@ -102,10 +96,6 @@ export function resolveSidebarItems($page, $site, $localePath) {
10296
}
10397
}
10498

105-
if(themeConfig.locales && themeConfig.locales[locale] && themeConfig.locales[locale].label) {
106-
languageTitle = themeConfig.locales[locale].label
107-
}
108-
10999
return {
110100
title: languageTitle,
111101
to: path,

0 commit comments

Comments
 (0)