5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 03:40:12 +08:00

feat(website): add translation progress (#2113)

* feat(website): add translation progress

* feat(website): add French and Portuguese to language list

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
Misite Bao 2022-11-21 19:19:34 +08:00 committed by GitHub
parent 91de3ab0c5
commit 51a12131a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3279 additions and 2997 deletions

View File

@ -4,8 +4,11 @@
const lightCodeTheme = require("prism-react-renderer/themes/github"); const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula"); const darkCodeTheme = require("prism-react-renderer/themes/dracula");
/** @type {import('@docusaurus/types').Config} */ const { getTranslationProgress } = require("./src/api/crowdin.js");
const config = {
module.exports = async function configCreatorAsync() {
const translationProgress = await getTranslationProgress();
return {
title: "Wails", title: "Wails",
tagline: "", tagline: "",
url: "https://wails.io", url: "https://wails.io",
@ -18,24 +21,24 @@ const config = {
webpack: { webpack: {
jsLoader: (isServer) => ({ jsLoader: (isServer) => ({
loader: require.resolve('swc-loader'), loader: require.resolve("swc-loader"),
options: { options: {
jsc: { jsc: {
parser: { parser: {
syntax: 'typescript', syntax: "typescript",
tsx: true, tsx: true,
}, },
target: 'es2017', target: "es2017",
}, },
module: { module: {
type: isServer ? 'commonjs' : 'es6', type: isServer ? "commonjs" : "es6",
}, },
}, },
}), }),
}, },
i18n: { i18n: {
defaultLocale: "en", defaultLocale: "en",
locales: ["en", "zh-Hans", "ja"], locales: ["en", "zh-Hans", "ja", "ru", "ko", "fr", "pt"],
localeConfigs: { localeConfigs: {
en: { en: {
label: "English", label: "English",
@ -43,25 +46,35 @@ const config = {
htmlLang: "en-US", htmlLang: "en-US",
}, },
"zh-Hans": { "zh-Hans": {
label: "简体中文", label: `简体中文 (${translationProgress["zh-CN"]}%)`,
direction: "ltr", direction: "ltr",
htmlLang: "zh-Hans", htmlLang: "zh-Hans",
}, },
ja: { ja: {
label: "日本語", label: `日本語 (${translationProgress["ja"]}%)`,
direction: "ltr", direction: "ltr",
htmlLang: "ja-JP", htmlLang: "ja-JP",
}, },
ru: { ru: {
label: "Русский", label: `Русский (${translationProgress["ru"]}%)`,
direction: "ltr", direction: "ltr",
htmlLang: "ru-RU", htmlLang: "ru-RU",
}, },
ko: { ko: {
label: "한국어", label: `한국어 (${translationProgress["ko"]}%)`,
direction: "ltr", direction: "ltr",
htmlLang: "ko-KR", htmlLang: "ko-KR",
}, },
fr: {
label: `Français (${translationProgress["fr"]}%)`,
direction: "ltr",
htmlLang: "fr",
},
pt: {
label: `Português (${translationProgress["pt-PT"]}%)`,
direction: "ltr",
htmlLang: "pt-PT",
},
}, },
}, },
plugins: [], plugins: [],
@ -78,7 +91,8 @@ const config = {
blog: { blog: {
showReadingTime: true, showReadingTime: true,
// Please change this to your repo. // Please change this to your repo.
editUrl: "https://github.com/wailsapp/wails/edit/master/website/blog", editUrl:
"https://github.com/wailsapp/wails/edit/master/website/blog",
}, },
theme: { theme: {
customCss: [ customCss: [
@ -256,6 +270,5 @@ const config = {
contextualSearch: true, contextualSearch: true,
}, },
}), }),
};
}; };
module.exports = config;

View File

@ -16,6 +16,7 @@
"crowdin:sync": "docusaurus write-translations && crowdin upload && crowdin download" "crowdin:sync": "docusaurus write-translations && crowdin upload && crowdin download"
}, },
"dependencies": { "dependencies": {
"@crowdin/crowdin-api-client": "^1.19.2",
"@docusaurus/core": "^2.1.0", "@docusaurus/core": "^2.1.0",
"@docusaurus/preset-classic": "^2.1.0", "@docusaurus/preset-classic": "^2.1.0",
"@docusaurus/theme-search-algolia": "^2.1.0", "@docusaurus/theme-search-algolia": "^2.1.0",

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
const crowdin = require("@crowdin/crowdin-api-client");
// initialization of crowdin client
const { translationStatusApi } = new crowdin.default({
token: process.env.CROWDIN_PERSONAL_TOKEN,
});
async function getTranslationProgress() {
let translationProgress = {};
await translationStatusApi.getProjectProgress(531392).then((res) => {
for (const item of res.data) {
translationProgress[item.data.languageId] = item.data.approvalProgress;
}
});
return translationProgress;
}
module.exports = {
getTranslationProgress,
};