1
0
mirror of https://github.com/go-task/task.git synced 2025-08-08 22:36:57 +02:00

feat(website): add translation progress

Closes #1173
Closes #1170
Closes #1102
This commit is contained in:
Misite Bao
2023-05-18 20:24:25 +08:00
committed by Andrey Nering
parent 3eab444c03
commit 785fc4ac3c
4 changed files with 315 additions and 189 deletions

View File

@@ -11,204 +11,227 @@ const {
const lightCodeTheme = require('./src/themes/prismLight');
const darkCodeTheme = require('./src/themes/prismDark');
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Task',
tagline: 'A task runner / simpler Make alternative written in Go ',
url: 'https://taskfile.dev',
baseUrl: '/',
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'throw',
favicon: 'img/favicon.ico',
const { getTranslationProgress } = require('./src/api/crowdin.js');
organizationName: 'go-task',
projectName: 'task',
deploymentBranch: 'gh-pages',
const getConfig = async () => {
const translationProgress = await getTranslationProgress();
i18n: {
defaultLocale: 'en',
locales: ['en', 'zh-Hans'],
localeConfigs: {
en: {
label: 'English',
direction: 'ltr',
htmlLang: 'en-US'
},
'zh-Hans': {
label: '简体中文',
direction: 'ltr',
htmlLang: 'zh-Hans'
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Task',
tagline: 'A task runner / simpler Make alternative written in Go ',
url: 'https://taskfile.dev',
baseUrl: '/',
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'throw',
favicon: 'img/favicon.ico',
organizationName: 'go-task',
projectName: 'task',
deploymentBranch: 'gh-pages',
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr-FR', 'pt-BR', 'ru-RU', 'zh-Hans'],
localeConfigs: {
en: {
label: 'English',
direction: 'ltr',
htmlLang: 'en-US'
},
'fr-FR': {
label: `Français (${translationProgress['fr'] || 0}%)`,
direction: 'ltr',
htmlLang: 'fr-FR'
},
'pt-BR': {
label: `Português (${translationProgress['pt-BR'] || 0}%)`,
direction: 'ltr',
htmlLang: 'pt-BR'
},
'ru-RU': {
label: `русский (${translationProgress['ru'] || 0}%)`,
direction: 'ltr',
htmlLang: 'ru-RU'
},
'zh-Hans': {
label: `简体中文 (${translationProgress['zh-CN'] || 0}%)`,
direction: 'ltr',
htmlLang: 'zh-Hans'
}
}
}
},
},
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
routeBasePath: '/',
sidebarPath: require.resolve('./sidebars.js')
},
blog: false,
theme: {
customCss: [require.resolve('./src/css/custom.css')]
},
gtag: {
trackingID: 'G-4RT25NXQ7N',
anonymizeIP: true
},
sitemap: {
changefreq: 'weekly',
priority: 0.5,
ignorePatterns: ['/tags/**']
}
})
]
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
docs: {
routeBasePath: '/',
sidebarPath: require.resolve('./sidebars.js')
metadata: [
{
name: 'og:image',
content: 'https://taskfile.dev/img/og-image.png'
}
],
navbar: {
title: 'Task',
logo: {
alt: 'Task Logo',
src: 'img/logo.svg'
},
items: [
{
type: 'doc',
docId: 'installation',
position: 'left',
label: 'Installation'
},
{
type: 'doc',
docId: 'usage',
position: 'left',
label: 'Usage'
},
{
type: 'doc',
docId: 'api_reference',
position: 'left',
label: 'API'
},
{
type: 'doc',
docId: 'donate',
position: 'left',
label: 'Donate'
},
{
type: 'localeDropdown',
position: 'left',
dropdownItemsAfter: [
{
to: '/translate/',
label: 'Help Us Translate'
}
]
},
{
href: GITHUB_URL,
label: 'GitHub',
position: 'right'
},
{
href: TWITTER_URL,
label: 'Twitter',
position: 'right'
},
{
href: MASTODON_URL,
label: 'Mastodon',
rel: 'me',
position: 'right'
},
{
href: DISCORD_URL,
label: 'Discord',
position: 'right'
}
]
},
blog: false,
theme: {
customCss: [require.resolve('./src/css/custom.css')]
footer: {
style: 'dark',
links: [
{
title: 'Pages',
items: [
{
label: 'Installation',
to: '/installation/'
},
{
label: 'Usage',
to: '/usage/'
},
{
label: 'Donate',
to: '/donate/'
}
]
},
{
title: 'Community',
items: [
{
label: 'GitHub',
href: GITHUB_URL
},
{
label: 'Twitter',
href: TWITTER_URL
},
{
label: 'Mastodon',
href: MASTODON_URL,
rel: 'me'
},
{
label: 'Discord',
href: DISCORD_URL
},
{
label: 'OpenCollective',
href: 'https://opencollective.com/task'
}
]
},
{
title: 'Translations',
items: [
{
label: 'Chinese | 中国人',
href: CHINESE_URL
}
]
}
]
},
gtag: {
trackingID: 'G-4RT25NXQ7N',
anonymizeIP: true
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme
},
sitemap: {
changefreq: 'weekly',
priority: 0.5,
ignorePatterns: ['/tags/**']
// NOTE(@andreynering): Don't worry, these keys are meant to be public =)
algolia: {
appId: '7IZIJ13AI7',
apiKey: '34b64ae4fc8d9da43d9a13d9710aaddc',
indexName: 'taskfile'
}
})
]
],
};
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
metadata: [
{
name: 'og:image',
content: 'https://taskfile.dev/img/og-image.png'
}
],
navbar: {
title: 'Task',
logo: {
alt: 'Task Logo',
src: 'img/logo.svg'
},
items: [
{
type: 'doc',
docId: 'installation',
position: 'left',
label: 'Installation'
},
{
type: 'doc',
docId: 'usage',
position: 'left',
label: 'Usage'
},
{
type: 'doc',
docId: 'api_reference',
position: 'left',
label: 'API'
},
{
type: 'doc',
docId: 'donate',
position: 'left',
label: 'Donate'
},
{
type: 'localeDropdown',
position: 'left',
dropdownItemsAfter: [
{
to: '/translate/',
label: 'Help Us Translate'
}
]
},
{
href: GITHUB_URL,
label: 'GitHub',
position: 'right'
},
{
href: TWITTER_URL,
label: 'Twitter',
position: 'right'
},
{
href: MASTODON_URL,
label: 'Mastodon',
rel: 'me',
position: 'right'
},
{
href: DISCORD_URL,
label: 'Discord',
position: 'right'
}
]
},
footer: {
style: 'dark',
links: [
{
title: 'Pages',
items: [
{
label: 'Installation',
to: '/installation/'
},
{
label: 'Usage',
to: '/usage/'
},
{
label: 'Donate',
to: '/donate/'
}
]
},
{
title: 'Community',
items: [
{
label: 'GitHub',
href: GITHUB_URL
},
{
label: 'Twitter',
href: TWITTER_URL
},
{
label: 'Mastodon',
href: MASTODON_URL,
rel: 'me'
},
{
label: 'Discord',
href: DISCORD_URL
},
{
label: 'OpenCollective',
href: 'https://opencollective.com/task'
}
]
},
{
title: 'Translations',
items: [
{
label: 'Chinese | 中国人',
href: CHINESE_URL
}
]
}
]
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme
},
// NOTE(@andreynering): Don't worry, these keys are meant to be public =)
algolia: {
appId: '7IZIJ13AI7',
apiKey: '34b64ae4fc8d9da43d9a13d9710aaddc',
indexName: 'taskfile'
}
})
return config;
};
module.exports = config;
module.exports = getConfig;

View File

@@ -25,6 +25,7 @@
},
"devDependencies": {
"@crowdin/cli": "^3.10.1",
"@crowdin/crowdin-api-client": "^1.22.1",
"@docusaurus/module-type-aliases": "^2.3.1"
},
"browserslist": {

50
docs/src/api/crowdin.js Normal file
View File

@@ -0,0 +1,50 @@
const crowdin = require('@crowdin/crowdin-api-client');
const personalToken = process.env.CROWDIN_PERSONAL_TOKEN;
const projectId = '574591';
/**
* Initialization of crowdin client
* @return {object} crowdin client
*/
const initClient = () => {
if (!personalToken) {
console.warn(
'No crowding personal token, some features might not work as expected'
);
return null;
}
return new crowdin.default({
token: personalToken
});
};
/**
* Get translation progress
* @return {object} translation progress
*/
async function getTranslationProgress() {
let translationProgress = {};
const { translationStatusApi } = initClient() || {};
if (!translationStatusApi) {
return translationProgress;
}
await translationStatusApi
.getProjectProgress(projectId)
.then((res) => {
res.data.forEach((item) => {
translationProgress[item.data.languageId] = item.data.approvalProgress;
});
})
.catch((err) => {
console.error(err);
});
return translationProgress;
}
module.exports = {
getTranslationProgress
};

View File

@@ -2149,6 +2149,13 @@
tar "^4.4.8"
yauzl "^2.10.0"
"@crowdin/crowdin-api-client@^1.22.1":
version "1.22.1"
resolved "https://registry.yarnpkg.com/@crowdin/crowdin-api-client/-/crowdin-api-client-1.22.1.tgz#30b42be256b8667158feda67b718d319dc8e35eb"
integrity sha512-2T4JWuatKBpdb8zYUd0HmXjOD3HCCd7I6LKWG7ZEVid9+JAXItjB8+xLL+AupYJM8iHflnZjggs/wadQZovOuA==
dependencies:
axios "^1"
"@docsearch/css@3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.3.0.tgz#d698e48302d12240d7c2f7452ccb2d2239a8cd80"
@@ -3499,6 +3506,11 @@ asap@~2.0.3:
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
integrity sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==
asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
@@ -3523,6 +3535,15 @@ axios@^0.25.0:
dependencies:
follow-redirects "^1.14.7"
axios@^1:
version "1.4.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f"
integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
proxy-from-env "^1.1.0"
babel-loader@^8.2.5:
version "8.2.5"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.5.tgz#d45f585e654d5a5d90f5350a779d7647c5ed512e"
@@ -4012,6 +4033,13 @@ combine-promises@^1.1.0:
resolved "https://registry.yarnpkg.com/combine-promises/-/combine-promises-1.1.0.tgz#72db90743c0ca7aab7d0d8d2052fd7b0f674de71"
integrity sha512-ZI9jvcLDxqwaXEixOhArm3r7ReIivsXkpbyEWyeOhzz1QS0iSgBPnWvEqvIQtYyamGCYA88gFhmUrs9hrrQ0pg==
combined-stream@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
dependencies:
delayed-stream "~1.0.0"
comma-separated-tokens@^1.0.0:
version "1.0.8"
resolved "https://registry.yarnpkg.com/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz#632b80b6117867a158f1080ad498b2fbe7e3f5ea"
@@ -4432,6 +4460,11 @@ del@^6.1.1:
rimraf "^3.0.2"
slash "^3.0.0"
delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
depd@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df"
@@ -4990,6 +5023,11 @@ follow-redirects@^1.0.0, follow-redirects@^1.14.7:
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5"
integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==
follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
fork-ts-checker-webpack-plugin@^6.5.0:
version "6.5.2"
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-6.5.2.tgz#4f67183f2f9eb8ba7df7177ce3cf3e75cdafb340"
@@ -5009,6 +5047,15 @@ fork-ts-checker-webpack-plugin@^6.5.0:
semver "^7.3.2"
tapable "^1.0.0"
form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"
forwarded@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
@@ -6169,7 +6216,7 @@ mime-types@2.1.18:
dependencies:
mime-db "~1.33.0"
mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34:
mime-types@^2.1.12, mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34:
version "2.1.35"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
@@ -7040,6 +7087,11 @@ proxy-addr@~2.0.7:
forwarded "0.2.0"
ipaddr.js "1.9.1"
proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
pump@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"