From acbf44a8603aeec2efeff14c4fbd3764753dfa97 Mon Sep 17 00:00:00 2001 From: sqrtthree Date: Sun, 22 Jul 2018 18:29:06 +0800 Subject: [PATCH] :recycle: refactor: Refactor i18n of sidebar Signed-off-by: sqrtthree --- utils.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/utils.js b/utils.js index 9878a31..a4373a6 100644 --- a/utils.js +++ b/utils.js @@ -75,20 +75,14 @@ export function resolveSidebarItems($page, $site, $localePath) { let languageSelectText if ($site.locales) { - let localeTheme = {}; - - if (themeConfig.locales) { - localeTheme = themeConfig.locales[$localePath] - } - - languageSelectText = localeTheme.selectText || 'languages' + languageSelectText = config.get($site, 'selectText', $localePath) || 'languages' sidebars[languageSelectText] = { title: languageSelectText, children: Object.keys($site.locales).map(locale => { const item = $site.locales[locale] + let languageTitle = config.get($site, 'label', locale) || item.text || item.lang let path - let languageTitle = item.text || item.lang if (item.path === $localePath) { path = $page.path // Stay on the current page @@ -102,10 +96,6 @@ export function resolveSidebarItems($page, $site, $localePath) { } } - if(themeConfig.locales && themeConfig.locales[locale] && themeConfig.locales[locale].label) { - languageTitle = themeConfig.locales[locale].label - } - return { title: languageTitle, to: path,