Skip to content

Commit

Permalink
refactor: add translations to color scheme list (#76)
Browse files Browse the repository at this point in the history
* Add archive layout

* Correct posts range

Correct posts range in custom theme's archive layout
so that doc pages don't get accidentally archived in posts archive
layout.

* Force HTTPS

* Add Chinese support for light switch

* Normalize Archive page CSS style

* Separate archive content from article div

* Remove archive layout for feature exclusion

* refactor: change translations

Co-authored-by: Wang Chucheng <[email protected]>
  • Loading branch information
junleqian and wangchucheng authored Mar 6, 2021
1 parent 4d319a1 commit 3668996
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
7 changes: 4 additions & 3 deletions assets/js/eureka.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ function getcolorscheme() {

for (let target of targets) {
target.addEventListener('click', () => {
let icon = switchMode(target.innerHTML)
let targetName = target.getAttribute("name")
let icon = switchMode(targetName)
let old_icon = element.firstElementChild.getAttribute("data-icon")
element.firstElementChild.setAttribute("data-icon", icon)
element.firstElementChild.classList.remove('fa-' + old_icon)
element.firstElementChild.classList.add('fa-' + icon)

localStorage.setItem("lightDarkMode", target.innerHTML)
localStorage.setItem("lightDarkMode", targetName)

targetDiv.classList.toggle('hidden')
screen.classList.toggle('hidden')
Expand Down Expand Up @@ -260,4 +261,4 @@ function switchDocVersion() {
element.lastElementChild.classList.toggle('fa-caret-right');
element.lastElementChild.classList.toggle('fa-caret-down');
})
}
}
8 changes: 7 additions & 1 deletion i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ recent:
onThisPage:
other: On This Page
editThisPage:
other: Edit this page
other: Edit this page
light:
other: Light
dark:
other: Dark
auto:
other: Auto
8 changes: 7 additions & 1 deletion i18n/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ recent:
onThisPage:
other: 本页内容
editThisPage:
other: 编辑本页
other: 编辑本页
light:
other: 浅色
dark:
other: 深色
auto:
other: 自动
10 changes: 5 additions & 5 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
</div>
<div class="absolute flex flex-col left-0 md:left-auto right-auto md:right-0 hidden bg-secondary-bg w-48 rounded py-2 border border-tertiary-bg cursor-pointer z-40"
id='lightDarkOptions'>
<span class="px-4 py-1 hover:text-eureka">Light</span>
<span class="px-4 py-1 hover:text-eureka">Dark</span>
<span class="px-4 py-1 hover:text-eureka">Auto</span>
<span class="px-4 py-1 hover:text-eureka" name="Light">{{i18n "light"}}</span>
<span class="px-4 py-1 hover:text-eureka" name="Dark">{{i18n "dark"}}</span>
<span class="px-4 py-1 hover:text-eureka" name="Auto">{{i18n "auto"}}</span>
</div>
</div>

Expand Down Expand Up @@ -118,12 +118,12 @@
element.firstElementChild.classList.add('fa-moon')
}
{{- end }}

document.addEventListener('DOMContentLoaded', () => {
getcolorscheme();
switchBurger();
{{- if .IsTranslated }}
switchLanguage()
{{- end }}
});
</script>
</script>

0 comments on commit 3668996

Please sign in to comment.