-
Notifications
You must be signed in to change notification settings - Fork 0
/
lang.js
60 lines (55 loc) ยท 1.97 KB
/
lang.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const lang = {
en: {
font: 'SuseongHyejeong',
title: "Online Stopwatch",
START: "START",
STOP: "STOP",
LAP: "LAP",
RESET: "RESET",
TotalTime: "Total Time",
HideTime: "Hide Current Time",
HideMs: "Hide Milliseconds",
DarkMode: "Dark Mode",
Discript: "The online stopwatch can be started by pressing the <b>START</b> button. Press the <b>STOP</b> button to stop the operation.</br> The lap time is recorded when the <b>LAP</b> button is pressed during the stopwatch operation.</br> Press the <b>RESET</b> button if you want to reset."
},
ko: {
font: 'EarlyFontDiary',
title: "์จ๋ผ์ธ ์คํฑ์์น",
START: "์์",
STOP: "์ ์ง",
LAP: "๋ฉ",
RESET: "์ด๊ธฐํ",
TotalTime: "์ ์ฒด ์๊ฐ",
HideTime: "ํ์ฌ ์๊ฐ ์จ๊ธฐ๊ธฐ",
HideMs: "๋ฐ๋ฆฌ์ด ์จ๊ธฐ๊ธฐ",
DarkMode: "๋คํฌ๋ชจ๋",
Discript: "์จ๋ผ์ธ ์คํฑ์์น๋ <b>์์</b> ๋ฒํผ์ ๋๋ฌ ์์ํ ์ ์์ต๋๋ค. ๋์์ ์ค์งํ๋ ค๋ฉด <b>์ ์ง</b> ๋ฒํผ์ ๋๋ฅด์ธ์.</br> ์คํฑ์์น ์๋ ์ค <b>๋ฉ</b> ๋ฒํผ์ ๋๋ฅด๋ฉด ๋ฉํ์์ด ๊ธฐ๋ก๋ฉ๋๋ค.</br> ์ด๊ธฐํ๋ฅผ ์ํ ์ <b>์ด๊ธฐํ</b> ๋ฒํผ์ ๋๋ฌ์ฃผ์ธ์."
},
};
// ** ํ์ฌ ๋ธ๋ผ์ฐ์ ์ ์ธ์ด ๊ฐ์ ธ์ค๊ธฐ **
function getLanguage() {
return navigator.language || navigator.userLanguage;
}
// ์ธ์ด๋ณ ์ ์ฉ
// function init(localeStr) {
// document.getElementById("locale").textContent = localeStr;
// }
// ์ด๊ธฐ ์์
const currentLang = getLanguage();
// init(currentLang);
render(currentLang.substr(0, 2));
// ์ธ์ด๋ณ ๋ ๋๋ง
function render(locale) {
const $lang = document.querySelectorAll("[data-lang]");
document.fontFamily = lang[locale][0];
$lang.forEach(el => {
const code = el.dataset.lang;
el.innerHTML = lang[locale][code];
})
}
// document.getElementById("btn-en").addEventListener("click", e => {
// render("en")
// })
// document.getElementById("btn-ko").addEventListener("click", e => {
// render("ko")
// })