@docusaurus/core 3.9.2-canary-6436 → 3.9.2-canary-6437
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/build/build.js +9 -16
- package/lib/server/i18n.d.ts +5 -1
- package/lib/server/i18n.js +17 -9
- package/package.json +11 -11
|
@@ -11,10 +11,9 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
12
|
const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
|
|
13
13
|
const utils_1 = require("@docusaurus/utils");
|
|
14
|
-
const site_1 = require("../../server/site");
|
|
15
14
|
const i18n_1 = require("../../server/i18n");
|
|
16
15
|
const buildLocale_1 = require("./buildLocale");
|
|
17
|
-
const
|
|
16
|
+
const config_1 = require("../../server/config");
|
|
18
17
|
async function build(siteDirParam = '.', cliOptions = {}) {
|
|
19
18
|
process.env.BABEL_ENV = 'production';
|
|
20
19
|
process.env.NODE_ENV = 'production';
|
|
@@ -50,24 +49,18 @@ function orderLocales({ locales, defaultLocale, }) {
|
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
async function getLocalesToBuild({ siteDir, cliOptions, }) {
|
|
53
|
-
|
|
54
|
-
// only loading siteConfig should be enough
|
|
55
|
-
const context = await (0, site_1.loadContext)({
|
|
52
|
+
const { siteConfig } = await (0, config_1.loadSiteConfig)({
|
|
56
53
|
siteDir,
|
|
57
|
-
|
|
58
|
-
config: cliOptions.config,
|
|
59
|
-
automaticBaseUrlLocalizationDisabled: (0, buildUtils_1.isAutomaticBaseUrlLocalizationDisabled)(cliOptions),
|
|
54
|
+
customConfigFilePath: cliOptions.config,
|
|
60
55
|
});
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
const locales = cliOptions.locale ?? i18n.locales;
|
|
56
|
+
const locales = cliOptions.locale ??
|
|
57
|
+
(0, i18n_1.loadI18nLocaleList)({
|
|
58
|
+
i18nConfig: siteConfig.i18n,
|
|
59
|
+
currentLocale: siteConfig.i18n.defaultLocale, // Awkward but ok
|
|
60
|
+
});
|
|
68
61
|
return orderLocales({
|
|
69
62
|
locales: locales,
|
|
70
|
-
defaultLocale: i18n.defaultLocale,
|
|
63
|
+
defaultLocale: siteConfig.i18n.defaultLocale,
|
|
71
64
|
});
|
|
72
65
|
}
|
|
73
66
|
async function tryToBuildLocale(params) {
|
package/lib/server/i18n.d.ts
CHANGED
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type { I18n, DocusaurusConfig, I18nLocaleConfig } from '@docusaurus/types';
|
|
7
|
+
import type { I18n, DocusaurusConfig, I18nLocaleConfig, I18nConfig } from '@docusaurus/types';
|
|
8
8
|
export declare function getDefaultLocaleConfig(locale: string): Omit<I18nLocaleConfig, 'translate' | 'url' | 'baseUrl'>;
|
|
9
|
+
export declare function loadI18nLocaleList({ i18nConfig, currentLocale, }: {
|
|
10
|
+
i18nConfig: I18nConfig;
|
|
11
|
+
currentLocale: string;
|
|
12
|
+
}): [string, ...string[]];
|
|
9
13
|
export declare function loadI18n({ siteDir, config, currentLocale, automaticBaseUrlLocalizationDisabled, }: {
|
|
10
14
|
siteDir: string;
|
|
11
15
|
config: DocusaurusConfig;
|
package/lib/server/i18n.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getDefaultLocaleConfig = getDefaultLocaleConfig;
|
|
10
|
+
exports.loadI18nLocaleList = loadI18nLocaleList;
|
|
10
11
|
exports.loadI18n = loadI18n;
|
|
11
12
|
const tslib_1 = require("tslib");
|
|
12
13
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -82,22 +83,29 @@ function getDefaultLocaleConfig(locale) {
|
|
|
82
83
|
};
|
|
83
84
|
}
|
|
84
85
|
catch (e) {
|
|
85
|
-
throw new Error(`Docusaurus couldn't
|
|
86
|
+
throw new Error(`Docusaurus couldn't infer a default locale config for ${logger_1.default.name(locale)}.
|
|
87
|
+
Make sure it is a valid BCP 47 locale name (e.g. en, fr, fr-FR, etc.) and/or provide a valid BCP 47 ${logger_1.default.code(`siteConfig.i18n.localeConfig['${locale}'].htmlLang`)} attribute.`, { cause: e });
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
|
-
|
|
89
|
-
const { i18n: i18nConfig } = config;
|
|
90
|
+
function loadI18nLocaleList({ i18nConfig, currentLocale, }) {
|
|
90
91
|
if (!i18nConfig.locales.includes(currentLocale)) {
|
|
91
|
-
logger_1.default.warn `The locale name=${currentLocale} was not found in your site configuration
|
|
92
|
-
|
|
92
|
+
logger_1.default.warn `The locale name=${currentLocale} was not found in your Docusaurus site configuration.
|
|
93
|
+
We recommend adding the name=${currentLocale} to your site i18n config, but we will still try to run your site.
|
|
94
|
+
Declared site config locales are: ${i18nConfig.locales}`;
|
|
95
|
+
return i18nConfig.locales.concat(currentLocale);
|
|
93
96
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
return i18nConfig.locales;
|
|
98
|
+
}
|
|
99
|
+
async function loadI18n({ siteDir, config, currentLocale, automaticBaseUrlLocalizationDisabled, }) {
|
|
100
|
+
const { i18n: i18nConfig } = config;
|
|
101
|
+
const locales = loadI18nLocaleList({
|
|
102
|
+
i18nConfig,
|
|
103
|
+
currentLocale,
|
|
104
|
+
});
|
|
97
105
|
async function getFullLocaleConfig(locale) {
|
|
98
106
|
const localeConfigInput = i18nConfig.localeConfigs[locale] ?? {};
|
|
99
107
|
const localeConfig = {
|
|
100
|
-
...getDefaultLocaleConfig(locale),
|
|
108
|
+
...getDefaultLocaleConfig(localeConfigInput.htmlLang ?? locale),
|
|
101
109
|
...localeConfigInput,
|
|
102
110
|
};
|
|
103
111
|
// By default, translations will be enabled if i18n/<locale> dir exists
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "3.9.2-canary-
|
|
4
|
+
"version": "3.9.2-canary-6437",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@docusaurus/babel": "3.9.2-canary-
|
|
37
|
-
"@docusaurus/bundler": "3.9.2-canary-
|
|
38
|
-
"@docusaurus/logger": "3.9.2-canary-
|
|
39
|
-
"@docusaurus/mdx-loader": "3.9.2-canary-
|
|
40
|
-
"@docusaurus/utils": "3.9.2-canary-
|
|
41
|
-
"@docusaurus/utils-common": "3.9.2-canary-
|
|
42
|
-
"@docusaurus/utils-validation": "3.9.2-canary-
|
|
36
|
+
"@docusaurus/babel": "3.9.2-canary-6437",
|
|
37
|
+
"@docusaurus/bundler": "3.9.2-canary-6437",
|
|
38
|
+
"@docusaurus/logger": "3.9.2-canary-6437",
|
|
39
|
+
"@docusaurus/mdx-loader": "3.9.2-canary-6437",
|
|
40
|
+
"@docusaurus/utils": "3.9.2-canary-6437",
|
|
41
|
+
"@docusaurus/utils-common": "3.9.2-canary-6437",
|
|
42
|
+
"@docusaurus/utils-validation": "3.9.2-canary-6437",
|
|
43
43
|
"boxen": "^6.2.1",
|
|
44
44
|
"chalk": "^4.1.2",
|
|
45
45
|
"chokidar": "^3.5.3",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"webpack-merge": "^6.0.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@docusaurus/module-type-aliases": "3.9.2-canary-
|
|
81
|
-
"@docusaurus/types": "3.9.2-canary-
|
|
80
|
+
"@docusaurus/module-type-aliases": "3.9.2-canary-6437",
|
|
81
|
+
"@docusaurus/types": "3.9.2-canary-6437",
|
|
82
82
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
83
83
|
"@types/detect-port": "^1.3.3",
|
|
84
84
|
"@types/react-dom": "^18.2.7",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"engines": {
|
|
99
99
|
"node": ">=20.0"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "c36f3ac2e06fc332b02fc2feaae5011d1a51ac87"
|
|
102
102
|
}
|