diff --git a/plugins/docusaurus-plugin-ionic-component-api/index.js b/plugins/docusaurus-plugin-ionic-component-api/index.js index e3784c6df67..8d9acb8c144 100644 --- a/plugins/docusaurus-plugin-ionic-component-api/index.js +++ b/plugins/docusaurus-plugin-ionic-component-api/index.js @@ -15,11 +15,15 @@ module.exports = function (context, options) { * Generates the markdown files for all components in a given version. * @param {*} version The version, e.g.: v6 * @param {*} npmTag The npm tag, e.g.: 6 or next + * @param {*} lang The language, e.g.: en or ja * @param {*} isCurrentVersion Whether or not this is the current version of the docs */ - const generateMarkdownForVersion = async (version, npmTag, isCurrentVersion) => { + const generateMarkdownForVersion = async (version, npmTag, lang, isCurrentVersion) => { let COMPONENT_LINK_REGEXP; - const response = await fetch(`https://unpkg.com/@ionic/docs@${npmTag}/core.json`); + const response = + isCurrentVersion && lang === 'ja' + ? await fetch(`https://raw.githubusercontent.com/ionic-jp/ionic-docs/main/scripts/data/translated-api.json`) + : await fetch(`https://unpkg.com/@ionic/docs@${npmTag}/core.json`); const { components } = await response.json(); const names = components.map((component) => component.tag.slice(4)); @@ -47,7 +51,7 @@ module.exports = function (context, options) { for (const version of options.versions) { const npmTag = version.slice(1); - await generateMarkdownForVersion(version, npmTag, false); + await generateMarkdownForVersion(version, npmTag, context.i18n.currentLocale, false); } let npmTag = 'latest'; @@ -57,7 +61,12 @@ module.exports = function (context, options) { npmTag = currentVersion.path.slice(1); } // Latest version - await generateMarkdownForVersion(currentVersion.path || currentVersion.label, npmTag, true); + await generateMarkdownForVersion( + currentVersion.path || currentVersion.label, + npmTag, + context.i18n.currentLocale, + true + ); return data; }, @@ -83,6 +92,7 @@ module.exports = function (context, options) { await Promise.all(promises); }, + configureWebpack(config, isServer, utils) { /** * Adds a custom import alias to the webpack configuration, so that the markdown files diff --git a/scripts/api-ja.mjs b/scripts/bak/api-ja.mjs similarity index 100% rename from scripts/api-ja.mjs rename to scripts/bak/api-ja.mjs diff --git a/scripts/i18n.sh b/scripts/i18n.sh index f31704215f7..9dae1be1306 100755 --- a/scripts/i18n.sh +++ b/scripts/i18n.sh @@ -5,4 +5,4 @@ set -o nounset mkdir -p i18n/ja/docusaurus-plugin-content-docs/current/ curl -fsSL https://github.com/ionic-team/ionic-docs/archive/refs/heads/translation/jp.tar.gz | tar -zxf - -C i18n/ja/docusaurus-plugin-content-docs/current/ --strip-components 2 ionic-docs-translation-jp/docs -node scripts/api-ja.mjs +# node scripts/api-ja.mjs