Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jason5ng32 committed Dec 24, 2024
1 parent d6f90f1 commit 051e476
Show file tree
Hide file tree
Showing 6 changed files with 718 additions and 670 deletions.
221 changes: 129 additions & 92 deletions frontend/components/advanced-tools/SecurityChecklist.vue

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
"Basic": "Basic",
"Optional": "Optional",
"Essential": "Essential",
"Advanced": "Advanced"
"Advanced": "Advanced",
"Reset":"Reset Checklist",
"ShowAll":"Show All",
"ShowUnchecked":"Show Unchecked",
"ShowIgnored":"Show Ignored",
"ShowChecked":"Show Checked"
},
"shell": {
"Title": "Command Line API",
Expand Down
7 changes: 6 additions & 1 deletion frontend/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
"Basic": "De base",
"Optional": "En option",
"Essential": "Essentiel",
"Advanced": "Avancé"
"Advanced": "Avancé",
"Reset": "Réinitialiser",
"ShowAll": "Afficher tout",
"ShowUnchecked": "Afficher les éléments non cochés",
"ShowIgnored": "Afficher les éléments ignorés",
"ShowChecked": "Afficher les éléments cochés"
},
"shell": {
"Title": "API de ligne de commande",
Expand Down
46 changes: 21 additions & 25 deletions frontend/locales/i18n.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
import { createI18n } from 'vue-i18n';


// 引入语言文件
import en from './en.json';
import zh from './zh.json';
import fr from './fr.json';

// 动态加载 security-checklist 语言文件
async function loadSecurityChecklistMessages(language) {
const module = await import(`./security-checklist/${language}.json`);
return module.default;
}

// 合并 security-checklist 到语言文件
async function mergeMessages() {
for (const lang of Object.keys(messages)) {
const checklistMessages = await loadSecurityChecklistMessages(lang);
messages[lang] = {
...messages[lang],
securitychecklistdata: checklistMessages
};
}
}
import enSecurity from './security-checklist/en.json';
import zhSecurity from './security-checklist/zh.json';
import frSecurity from './security-checklist/fr.json';


const messages = { en, zh, fr };
const supportedLanguages = Object.keys(messages);

// 引入安全检查清单
function mergeMessagesSync() {
messages.en = { ...messages.en, securitychecklistdata: enSecurity };
messages.zh = { ...messages.zh, securitychecklistdata: zhSecurity };
messages.fr = { ...messages.fr, securitychecklistdata: frSecurity };
}

// 设置语言
function setLanguage() {
let locale = 'en';
Expand All @@ -51,14 +44,21 @@ function setLanguage() {
return locale;
}

// 合并语言包
const messagesLoader = () => {
mergeMessagesSync();
return messages;
};

// 创建 i18n 实例
const i18n = createI18n({
legacy: false,
locale: setLanguage(),
fallbackLocale: 'en',
messages,
messages: messagesLoader(),
});

// 更新 meta 标签
function updateMeta() {
document.title = i18n.global.t('page.title');

Expand All @@ -72,9 +72,5 @@ function updateMeta() {
}
}

(async () => {
await mergeMessages();
updateMeta();
})();

export default i18n;
updateMeta();
export default i18n;
Loading

0 comments on commit 051e476

Please sign in to comment.