Skip to content

Commit

Permalink
♻️ refactor: Refactor i18n of sidebar
Browse files Browse the repository at this point in the history
Signed-off-by: sqrtthree <[email protected]>
  • Loading branch information
linhe0x0 committed Jul 22, 2018
1 parent a42f089 commit acbf44a
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit acbf44a

Please sign in to comment.