@@ -15,28 +15,17 @@ 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 components = await ( async ( ) => {
23- if ( isCurrentVersion ) {
24- const { components } = require ( process . cwd ( ) + `/scripts/data/translated-api.json` ) ;
25- return components ;
26- } else {
27- const response = isCurrentVersion
28- ? await fetch (
29- `https://raw.githubusercontent.com/ionic-jp/ionic-docs/main/scripts/data/translated-api.json`
30- )
31- : await fetch ( `https://unpkg.com/@ionic/docs@${ npmTag } /core.json` ) ;
32- const { components } = await response . json ( ) ;
33- return components ;
34- }
35- } ) ( ) ;
36- // const response = isCurrentVersion
37- // ? await fetch(`https://raw.githubusercontent.com/ionic-jp/ionic-docs/main/scripts/data/translated-api.json`)
38- // : await fetch(`https://unpkg.com/@ionic/docs@${npmTag}/core.json`);
39- // const { components } = await response.json();
23+ const response =
24+ isCurrentVersion && lang === 'ja'
25+ ? await fetch ( `https://raw.githubusercontent.com/ionic-jp/ionic-docs/main/scripts/data/translated-api.json` )
26+ : await fetch ( `https://unpkg.com/@ionic/docs@${ npmTag } /core.json` ) ;
27+ const { components } = await response . json ( ) ;
28+
4029 const names = components . map ( ( component ) => component . tag . slice ( 4 ) ) ;
4130 // matches all relative markdown links to a component, e.g. (../button)
4231 COMPONENT_LINK_REGEXP = new RegExp ( `\\(../(${ names . join ( '|' ) } )/?(#[^)]+)?\\)` , 'g' ) ;
@@ -61,7 +50,7 @@ module.exports = function (context, options) {
6150 for ( const version of options . versions ) {
6251 const npmTag = version . slice ( 1 ) ;
6352
64- await generateMarkdownForVersion ( version , npmTag , false ) ;
53+ await generateMarkdownForVersion ( version , npmTag , context . i18n . currentLocale , false ) ;
6554 }
6655
6756 let npmTag = 'latest' ;
@@ -71,7 +60,12 @@ module.exports = function (context, options) {
7160 npmTag = currentVersion . path . slice ( 1 ) ;
7261 }
7362 // Latest version
74- await generateMarkdownForVersion ( currentVersion . path || currentVersion . label , npmTag , true ) ;
63+ await generateMarkdownForVersion (
64+ currentVersion . path || currentVersion . label ,
65+ npmTag ,
66+ context . i18n . currentLocale ,
67+ true
68+ ) ;
7569
7670 return data ;
7771 } ,
@@ -97,6 +91,7 @@ module.exports = function (context, options) {
9791
9892 await Promise . all ( promises ) ;
9993 } ,
94+
10095 configureWebpack ( config , isServer , utils ) {
10196 /**
10297 * Adds a custom import alias to the webpack configuration, so that the markdown files
0 commit comments