WIP i18next
This commit is contained in:
@@ -26,6 +26,8 @@
|
|||||||
"cytoscape-popper": "^2.0.0",
|
"cytoscape-popper": "^2.0.0",
|
||||||
"date-fns": "^2.30.0",
|
"date-fns": "^2.30.0",
|
||||||
"decimal.js": "^10.4.3",
|
"decimal.js": "^10.4.3",
|
||||||
|
"i18next": "^23.11.5",
|
||||||
|
"i18next-browser-languagedetector": "^8.0.0",
|
||||||
"javascript-color-gradient": "^2.4.4",
|
"javascript-color-gradient": "^2.4.4",
|
||||||
"mitt": "^3.0.0",
|
"mitt": "^3.0.0",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
|
|||||||
5
src/i18n/en.json
Normal file
5
src/i18n/en.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"Compare": {
|
||||||
|
"avgCycleTimeTitle": "Average Cycle Time"
|
||||||
|
}
|
||||||
|
}
|
||||||
31
src/i18n/i18n.js
Normal file
31
src/i18n/i18n.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import i18next from 'i18next';
|
||||||
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
||||||
|
import enLocale from './en.json';
|
||||||
|
|
||||||
|
|
||||||
|
i18next
|
||||||
|
.use(LanguageDetector)
|
||||||
|
.init({
|
||||||
|
// 配置你的本地化選項
|
||||||
|
resources: {
|
||||||
|
en: enLocale,
|
||||||
|
de: {
|
||||||
|
translation: {
|
||||||
|
greeting: 'Hallo!'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 添加其他語言的翻譯
|
||||||
|
},
|
||||||
|
// 選擇默認的語言
|
||||||
|
fallbackLng: 'en',
|
||||||
|
|
||||||
|
// 在初始化時自動檢測用戶的語言
|
||||||
|
detection: {
|
||||||
|
order: ['localStorage', 'navigator'],
|
||||||
|
caches: ['localStorage']
|
||||||
|
},
|
||||||
|
|
||||||
|
// 選擇性配置其他選項...
|
||||||
|
});
|
||||||
|
|
||||||
|
export default i18next;
|
||||||
@@ -102,7 +102,9 @@ export function followTimeLabel(second, max, fixedNumber = 0) {
|
|||||||
*/
|
*/
|
||||||
export function dateLabel(date, maxDate, minDate) {
|
export function dateLabel(date, maxDate, minDate) {
|
||||||
// 將時間字串轉換為時間物件
|
// 將時間字串轉換為時間物件
|
||||||
// new Date(time) 之後不用 getTime(),因為在JavaScript中,日期物件是以時間戳記(timestamp)的形式存儲的。當創建一個新的日期物件時,它內部會自動轉換時間字串為時間戳記。
|
// new Date(time) 之後不用 getTime(),因為在JavaScript中,
|
||||||
|
// 日期物件是以時間戳記(timestamp)的形式存儲的。當創建一個新的日期物件時,
|
||||||
|
// 它內部會自動轉換時間字串為時間戳記。
|
||||||
date = new Date(date);
|
date = new Date(date);
|
||||||
maxDate = new Date(maxDate);
|
maxDate = new Date(maxDate);
|
||||||
minDate = new Date(minDate);
|
minDate = new Date(minDate);
|
||||||
|
|||||||
Reference in New Issue
Block a user