-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
210 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ node_modules | |
.env | ||
.vscode/settings.json | ||
build/ | ||
content/ | ||
content/ | ||
i18n/ | ||
!i18n/en/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
project_id: '273870' | ||
api_token_env: 'CROWDIN_PERSONAL_TOKEN' | ||
preserve_hierarchy: true | ||
files: [ | ||
# JSON translation files | ||
{ | ||
source: '/i18n/en/**/*', | ||
translation: '/i18n/%two_letters_code%/**/%original_file_name%', | ||
}, | ||
# Docs Markdown files | ||
{ | ||
source: '/docs/**/*', | ||
translation: '/i18n/%two_letters_code%/docusaurus-plugin-content-docs/current/**/%original_file_name%', | ||
ignore: ['/docs/**/fiddles', '/docs/**/images'], | ||
}, | ||
# Blog Markdown files | ||
{ | ||
source: '/blog/**/*', | ||
translation: '/i18n/%two_letters_code%/docusaurus-plugin-content-blog/**/%original_file_name%', | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//@ts-check | ||
const fs = require('fs').promises; | ||
const { join } = require('path'); | ||
const { execute } = require('./utils/execute'); | ||
const { | ||
i18n: { locales, defaultLocale }, | ||
} = require('../docusaurus.config'); | ||
|
||
const updateConfig = async (locale) => { | ||
const baseUrl = locale !== defaultLocale ? `/${locale}/` : '/'; | ||
// Translations might not be completely in sync and we need to keep publishing | ||
const onBrokenLinks = locale !== defaultLocale ? `warn` : `throw`; | ||
const configPath = join(__dirname, '../docusaurus.config.js'); | ||
|
||
let docusaurusConfig = await fs.readFile(configPath, 'utf-8'); | ||
|
||
docusaurusConfig = docusaurusConfig | ||
.replace(/baseUrl: '.*?',/, `baseUrl: '${baseUrl}',`) | ||
.replace(/onBrokenLinks: '.*?',/, `onBrokenLinks: '${onBrokenLinks}',`); | ||
|
||
await fs.writeFile(configPath, docusaurusConfig, 'utf-8'); | ||
}; | ||
|
||
const processLocale = async (locale) => { | ||
const start = Date.now(); | ||
const outdir = locale !== defaultLocale ? `--out-dir build/${locale}` : ''; | ||
await execute(`yarn docusaurus build --locale ${locale} ${outdir}`); | ||
console.log(`Locale ${locale} finished in ${(Date.now() - start) / 1000}s`); | ||
}; | ||
|
||
/** | ||
* | ||
* @param {string} [locale] | ||
*/ | ||
const start = async (locale) => { | ||
const start = Date.now(); | ||
|
||
const localesToBuild = locale ? [locale] : locales; | ||
|
||
console.log('Building the following locales:'); | ||
console.log(localesToBuild); | ||
|
||
try { | ||
for (const locale of localesToBuild) { | ||
await updateConfig(locale); | ||
await processLocale(locale); | ||
} | ||
} catch (e) { | ||
// We catch instead of just stopping the process because we want to restore docusaurus.config.js | ||
console.error(`e`); | ||
} | ||
// Restore `docusaurus.config.js` to the default values | ||
await updateConfig(defaultLocale); | ||
|
||
console.log(`Process finished in ${(Date.now() - start) / 1000}s`); | ||
}; | ||
|
||
start(process.argv[2]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//@ts-check | ||
|
||
/** | ||
* Takes care of downloading the documentation from the | ||
* right places, and transform it to make it ready to | ||
* be used by docusaurus. | ||
*/ | ||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
|
||
const { addFrontmatter } = require('./tasks/add-frontmatter'); | ||
const { fixContent } = require('./tasks/md-fixers'); | ||
|
||
const DOCS_FOLDER = path.join('docs', 'latest'); | ||
const { | ||
i18n: { locales: configuredLocales }, | ||
} = require('../docusaurus.config'); | ||
|
||
const start = async () => { | ||
const locales = new Set(configuredLocales); | ||
locales.delete('en'); | ||
for (const locale of locales) { | ||
const localeDocs = path.join( | ||
'i18n', | ||
locale, | ||
'docusaurus-plugin-content-docs', | ||
'current' | ||
); | ||
const staticResources = ['fiddles', 'images']; | ||
|
||
console.log(`Copying static assets to ${locale}`); | ||
for (const staticResource of staticResources) { | ||
await fs.copy( | ||
path.join(DOCS_FOLDER, staticResource), | ||
path.join(localeDocs, 'latest', staticResource) | ||
); | ||
} | ||
|
||
console.log(`Fixing markdown (${locale})`); | ||
await fixContent(localeDocs, 'latest'); | ||
|
||
console.log(`Adding automatic frontmatter (${locale})`); | ||
await addFrontmatter(path.join(localeDocs, 'latest')); | ||
} | ||
}; | ||
|
||
start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1310,6 +1310,13 @@ | |
exec-sh "^0.3.2" | ||
minimist "^1.2.0" | ||
|
||
"@crowdin/cli@3": | ||
version "3.7.0" | ||
resolved "https://registry.yarnpkg.com/@crowdin/cli/-/cli-3.7.0.tgz#d35b69e90b6a737a9de017423ac34c02291cdebb" | ||
integrity sha512-7eje7V6BGMeW23ywbrYdvpdIIxG5O1WP2wit4MVP9EtuZMOfr1M0l9BnObbkSYK86UiZuoJFHs1Q1KoCWg1rlA== | ||
dependencies: | ||
shelljs "^0.8.4" | ||
|
||
"@docsearch/[email protected]": | ||
version "3.0.0-alpha.39" | ||
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.0.0-alpha.39.tgz#1ebd390d93e06aad830492f5ffdc8e05d058813f" | ||
|