Skip to content

Commit 627c8b6

Browse files
committed
fix(translate): fix api content and remove api-ja.mjs
1 parent 763216f commit 627c8b6

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

plugins/docusaurus-plugin-ionic-component-api/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ module.exports = function (context, options) {
1515
* Generates the markdown files for all components in a given version.
1616
* @param {*} version The version, e.g.: v6
1717
* @param {*} npmTag The npm tag, e.g.: 6 or next
18+
* @param {*} lang The language, e.g.: en or ja
1819
* @param {*} isCurrentVersion Whether or not this is the current version of the docs
1920
*/
20-
const generateMarkdownForVersion = async (version, npmTag, isCurrentVersion) => {
21+
const generateMarkdownForVersion = async (version, npmTag, lang, isCurrentVersion) => {
2122
let COMPONENT_LINK_REGEXP;
22-
const response = await fetch(`https://unpkg.com/@ionic/docs@${npmTag}/core.json`);
23+
const response = isCurrentVersion && lang === 'ja'
24+
? await fetch(`https://raw.githubusercontent.com/ionic-jp/ionic-docs/main/scripts/data/translated-api.json`)
25+
: await fetch(`https://unpkg.com/@ionic/docs@${npmTag}/core.json`);
2326
const { components } = await response.json();
2427

2528
const names = components.map((component) => component.tag.slice(4));
@@ -47,7 +50,7 @@ module.exports = function (context, options) {
4750
for (const version of options.versions) {
4851
const npmTag = version.slice(1);
4952

50-
await generateMarkdownForVersion(version, npmTag, false);
53+
await generateMarkdownForVersion(version, npmTag, context.i18n.currentLocale, false);
5154
}
5255

5356
let npmTag = 'latest';
@@ -57,7 +60,7 @@ module.exports = function (context, options) {
5760
npmTag = currentVersion.path.slice(1);
5861
}
5962
// Latest version
60-
await generateMarkdownForVersion(currentVersion.path || currentVersion.label, npmTag, true);
63+
await generateMarkdownForVersion(currentVersion.path || currentVersion.label, npmTag, context.i18n.currentLocale, true);
6164

6265
return data;
6366
},
@@ -83,6 +86,7 @@ module.exports = function (context, options) {
8386

8487
await Promise.all(promises);
8588
},
89+
8690
configureWebpack(config, isServer, utils) {
8791
/**
8892
* Adds a custom import alias to the webpack configuration, so that the markdown files
File renamed without changes.

scripts/i18n.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -o nounset
55
mkdir -p i18n/ja/docusaurus-plugin-content-docs/current/
66
curl -fsSL https://github.com/ionic-team/ionic-docs/archive/refs/heads/translation/jp.tar.gz |
77
tar -zxf - -C i18n/ja/docusaurus-plugin-content-docs/current/ --strip-components 2 ionic-docs-translation-jp/docs
8-
node scripts/api-ja.mjs
8+
# node scripts/api-ja.mjs

0 commit comments

Comments
 (0)