Skip to content

Commit 82d1806

Browse files
committed
build: add crowdin support for i18n
1 parent 37aa21d commit 82d1806

File tree

6 files changed

+47
-11
lines changed

6 files changed

+47
-11
lines changed

.github/workflows/deploy.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
run: |
1919
yarn install --frozen-lockfile
2020
yarn run remote-download
21+
yarn run crowdin:sync
2122
yarn build
2223
2324
# Popular action to deploy to GitHub Pages:

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# Production
55
/build
66

7+
# i18n
8+
/i18n
9+
710
# IDE
811
.idea
912

crowdin.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
project_id: '493041'
2+
api_token_env: CROWDIN_PERSONAL_TOKEN
3+
preserve_hierarchy: true
4+
files:
5+
# JSON translation files
6+
- source: /i18n/en/**/*
7+
translation: /i18n/%two_letters_code%/**/%original_file_name%
8+
# Docs Markdown files
9+
- source: /docs/**/*
10+
translation: /i18n/%two_letters_code%/docusaurus-plugin-content-docs/current/**/%original_file_name%
11+
ignore:
12+
- /docs/**/_remote
13+
# Blog Markdown files
14+
# - source: /blog/**/*
15+
# translation: /i18n/%two_letters_code%/docusaurus-plugin-content-blog/**/%original_file_name%

docusaurus.config.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
const lightCodeTheme = require('prism-react-renderer/themes/github')
55
const darkCodeTheme = require('prism-react-renderer/themes/dracula')
6+
const DefaultLocale = 'en';
7+
68

79
/** @type {import('@docusaurus/types').Config} */
810
const config = {
@@ -18,10 +20,10 @@ const config = {
1820
deploymentBranch: 'gh-pages',
1921
trailingSlash: false,
2022

21-
// i18n: {
22-
// defaultLocale: 'en',
23-
// locales: ['en', 'fr'],
24-
// },
23+
i18n: {
24+
defaultLocale: 'en',
25+
locales: ['en', 'fr'],
26+
},
2527

2628
plugins: [
2729
[
@@ -57,8 +59,13 @@ const config = {
5759
({
5860
docs: {
5961
sidebarPath: require.resolve('./sidebars.js'),
60-
// Please change this to your repo.
61-
editUrl: 'https://github.com/anansi-project/anansi-project.github.io/edit/main/',
62+
editUrl: ({locale, docPath}) => {
63+
// Link to Crowdin
64+
if (locale !== DefaultLocale) {
65+
return `https://crowdin.com/project/anansi-project/${locale}`;
66+
}
67+
return `https://github.com/anansi-project/anansi-project.github.io/edit/main/docs/${docPath}`;
68+
},
6269
},
6370
// blog: {
6471
// showReadingTime: true,
@@ -90,10 +97,10 @@ const config = {
9097
label: 'Documentation',
9198
},
9299
// { to: '/blog', label: 'Blog', position: 'left' },
93-
// {
94-
// type: 'localeDropdown',
95-
// position: 'right',
96-
// },
100+
{
101+
type: 'localeDropdown',
102+
position: 'right',
103+
},
97104
{
98105
href: 'https://github.com/anansi-project',
99106
label: 'GitHub',

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
"write-heading-ids": "docusaurus write-heading-ids",
1515
"typecheck": "tsc",
1616
"remote-download": "docusaurus download-remote-comicinfo && docusaurus download-remote-opds-pse",
17-
"remote-clear": "docusaurus clear-remote-comicinfo && docusaurus clear-remote-opds-pse"
17+
"remote-clear": "docusaurus clear-remote-comicinfo && docusaurus clear-remote-opds-pse",
18+
"crowdin": "crowdin",
19+
"crowdin:sync": "docusaurus write-translations && crowdin upload && crowdin download"
1820
},
1921
"dependencies": {
22+
"@crowdin/cli": "3",
2023
"@docusaurus/core": "2.0.0-beta.13",
2124
"@docusaurus/preset-classic": "2.0.0-beta.13",
2225
"@mdx-js/react": "^1.6.21",

yarn.lock

+7
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,13 @@
11621162
"@babel/helper-validator-identifier" "^7.15.7"
11631163
to-fast-properties "^2.0.0"
11641164

1165+
"@crowdin/cli@3":
1166+
version "3.7.4"
1167+
resolved "https://registry.yarnpkg.com/@crowdin/cli/-/cli-3.7.4.tgz#5600d8c90d4416325a166fe0cbe339340cebd3af"
1168+
integrity sha512-gxoJvxq282PWdCQvNRH03wWqBwEXJYlM2aBng5ZbffHLQXVQw7idIeghYJ/7TTwzyXkibq06YPkgAaaJJaoLiw==
1169+
dependencies:
1170+
shelljs "^0.8.4"
1171+
11651172
"@docsearch/[email protected]":
11661173
version "3.0.0-alpha.42"
11671174
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.0.0-alpha.42.tgz#deb6049e999d6ca9451eba4793cb5b6da28c8773"

0 commit comments

Comments
 (0)