@docusaurus/utils 3.8.1-canary-6373 → 3.8.1-canary-6374
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/i18nUtils.d.ts +0 -26
- package/lib/i18nUtils.d.ts.map +1 -1
- package/lib/i18nUtils.js +0 -24
- package/lib/i18nUtils.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -3
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/src/i18nUtils.ts +0 -49
- package/src/index.ts +0 -1
package/lib/i18nUtils.d.ts
CHANGED
|
@@ -24,31 +24,5 @@ export declare function getPluginI18nPath({ localizationDir, pluginName, pluginI
|
|
|
24
24
|
pluginId?: string | undefined;
|
|
25
25
|
subPaths?: string[];
|
|
26
26
|
}): string;
|
|
27
|
-
/**
|
|
28
|
-
* Takes a path and returns a localized a version (which is basically `path +
|
|
29
|
-
* i18n.currentLocale`).
|
|
30
|
-
*
|
|
31
|
-
* This is used to resolve the `outDir` and `baseUrl` of each locale; it is NOT
|
|
32
|
-
* used to determine plugin localization file locations.
|
|
33
|
-
*/
|
|
34
|
-
export declare function localizePath({ pathType, path: originalPath, i18n, options, }: {
|
|
35
|
-
/**
|
|
36
|
-
* FS paths will treat Windows specially; URL paths will always have a
|
|
37
|
-
* trailing slash to make it a valid base URL.
|
|
38
|
-
*/
|
|
39
|
-
pathType: 'fs' | 'url';
|
|
40
|
-
/** The path, URL or file path, to be localized. */
|
|
41
|
-
path: string;
|
|
42
|
-
/** The current i18n context. */
|
|
43
|
-
i18n: I18n;
|
|
44
|
-
options?: {
|
|
45
|
-
/**
|
|
46
|
-
* By default, we don't localize the path of defaultLocale. This option
|
|
47
|
-
* would override that behavior. Setting `false` is useful for `yarn build
|
|
48
|
-
* -l zh-Hans` to always emit into the root build directory.
|
|
49
|
-
*/
|
|
50
|
-
localizePath?: boolean;
|
|
51
|
-
};
|
|
52
|
-
}): string;
|
|
53
27
|
export declare function getLocaleConfig(i18n: I18n, locale?: string): I18nLocaleConfig;
|
|
54
28
|
//# sourceMappingURL=i18nUtils.d.ts.map
|
package/lib/i18nUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nUtils.d.ts","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"i18nUtils.d.ts","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,IAAI,EACJ,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,sBAAsB,EAAE,GACjC,sBAAsB,CAExB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GACzC,eAAe,CAQjB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,eAAe,EACf,UAAU,EACV,QAA4B,EAC5B,QAAa,GACd,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,GAAG,MAAM,CAQT;AAKD,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAS7E"}
|
package/lib/i18nUtils.js
CHANGED
|
@@ -9,14 +9,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.mergeTranslations = mergeTranslations;
|
|
10
10
|
exports.updateTranslationFileMessages = updateTranslationFileMessages;
|
|
11
11
|
exports.getPluginI18nPath = getPluginI18nPath;
|
|
12
|
-
exports.localizePath = localizePath;
|
|
13
12
|
exports.getLocaleConfig = getLocaleConfig;
|
|
14
13
|
const tslib_1 = require("tslib");
|
|
15
14
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
16
15
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
17
16
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
18
17
|
const constants_1 = require("./constants");
|
|
19
|
-
const urlUtils_1 = require("./urlUtils");
|
|
20
18
|
/**
|
|
21
19
|
* Takes a list of translation file contents, and shallow-merges them into one.
|
|
22
20
|
*/
|
|
@@ -46,28 +44,6 @@ function getPluginI18nPath({ localizationDir, pluginName, pluginId = constants_1
|
|
|
46
44
|
// ie: return "docs", not "docs-default" nor "docs/default"
|
|
47
45
|
`${pluginName}${pluginId === constants_1.DEFAULT_PLUGIN_ID ? '' : `-${pluginId}`}`, ...subPaths);
|
|
48
46
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Takes a path and returns a localized a version (which is basically `path +
|
|
51
|
-
* i18n.currentLocale`).
|
|
52
|
-
*
|
|
53
|
-
* This is used to resolve the `outDir` and `baseUrl` of each locale; it is NOT
|
|
54
|
-
* used to determine plugin localization file locations.
|
|
55
|
-
*/
|
|
56
|
-
function localizePath({ pathType, path: originalPath, i18n, options = {}, }) {
|
|
57
|
-
const shouldLocalizePath = options.localizePath ?? i18n.currentLocale !== i18n.defaultLocale;
|
|
58
|
-
if (!shouldLocalizePath) {
|
|
59
|
-
return originalPath;
|
|
60
|
-
}
|
|
61
|
-
// FS paths need special care, for Windows support. Note: we don't use the
|
|
62
|
-
// locale config's `path` here, because this function is used for resolving
|
|
63
|
-
// outDir, which must be the same as baseUrl. When we have the baseUrl config,
|
|
64
|
-
// we need to sync the two.
|
|
65
|
-
if (pathType === 'fs') {
|
|
66
|
-
return path_1.default.join(originalPath, i18n.currentLocale);
|
|
67
|
-
}
|
|
68
|
-
// Url paths; add a trailing slash so it's a valid base URL
|
|
69
|
-
return (0, urlUtils_1.normalizeUrl)([originalPath, i18n.currentLocale, '/']);
|
|
70
|
-
}
|
|
71
47
|
// TODO we may extract this to a separate package
|
|
72
48
|
// we want to use it on the frontend too
|
|
73
49
|
// but "docusaurus-utils-common" (agnostic utils) is not an ideal place since
|
package/lib/i18nUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nUtils.js","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;
|
|
1
|
+
{"version":3,"file":"i18nUtils.js","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAgBH,8CAIC;AAMD,sEAWC;AAMD,8CAkBC;AAKD,0CASC;;AAzED,wDAAwB;AACxB,4DAAuB;AACvB,wEAAwC;AACxC,2CAA8C;AAQ9C;;GAEG;AACH,SAAgB,iBAAiB,CAC/B,QAAkC;IAElC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,GAAG,EAAE,GAAG,OAAO,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAC3C,eAAgC,EAChC,aAA0C;IAE1C,OAAO;QACL,GAAG,eAAe;QAClB,OAAO,EAAE,gBAAC,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC9D,GAAG,WAAW;YACd,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC;SAC5C,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,EAChC,eAAe,EACf,UAAU,EACV,QAAQ,GAAG,6BAAiB,EAC5B,QAAQ,GAAG,EAAE,GAMd;IACC,OAAO,cAAI,CAAC,IAAI,CACd,eAAe;IACf,gDAAgD;IAChD,2DAA2D;IAC3D,GAAG,UAAU,GAAG,QAAQ,KAAK,6BAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,EAAE,EACtE,GAAG,QAAQ,CACZ,CAAC;AACJ,CAAC;AAED,iDAAiD;AACjD,yCAAyC;AACzC,8EAA8E;AAC9E,SAAgB,eAAe,CAAC,IAAU,EAAE,MAAe;IACzD,MAAM,eAAe,GAAG,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC;IACrD,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACzD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACb,uCAAuC,gBAAM,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CACtE,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export { NODE_MAJOR_VERSION, NODE_MINOR_VERSION, DOCUSAURUS_VERSION, DEFAULT_BUILD_DIR_NAME, DEFAULT_CONFIG_FILE_NAME, BABEL_CONFIG_FILE_NAME, GENERATED_FILES_DIR_NAME, SRC_DIR_NAME, DEFAULT_STATIC_DIR_NAME, OUTPUT_STATIC_ASSETS_DIR_NAME, THEME_PATH, DEFAULT_I18N_DIR_NAME, CODE_TRANSLATIONS_FILE_NAME, DEFAULT_PORT, DEFAULT_PLUGIN_ID, WEBPACK_URL_LOADER_LIMIT, } from './constants';
|
|
8
8
|
export { generate, readOutputHTMLFile } from './emitUtils';
|
|
9
9
|
export { getFileCommitDate, FileNotTrackedError, GitNotFoundError, } from './gitUtils';
|
|
10
|
-
export { mergeTranslations, updateTranslationFileMessages, getPluginI18nPath,
|
|
10
|
+
export { mergeTranslations, updateTranslationFileMessages, getPluginI18nPath, getLocaleConfig, } from './i18nUtils';
|
|
11
11
|
export { mapAsyncSequential, findAsyncSequential } from './jsUtils';
|
|
12
12
|
export { normalizeUrl, getEditUrl, fileToPath, encodePath, isValidPathname, resolvePathname, parseURLPath, parseLocalURLPath, parseURLOrPath, toURLPath, serializeURLPath, hasSSHProtocol, buildHttpsUrl, buildSshUrl, } from './urlUtils';
|
|
13
13
|
export type { URLPath } from './urlUtils';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAC,M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E,UAAU,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,UAAU,EACV,2BAA2B,EAC3B,aAAa,EACb,6BAA6B,GAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,QAAQ,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.DEFAULT_PARSE_FRONT_MATTER = exports.createExcerpt = exports.admonitionTitleToDirectiveLabel = exports.unwrapMdxCodeBlocks = exports.escapeMarkdownHeadingIds = exports.parseMarkdownHeadingId = exports.getTagVisibility = exports.groupTaggedItems = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.serializeURLPath = exports.toURLPath = exports.parseURLOrPath = exports.parseLocalURLPath = exports.parseURLPath = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.getLocaleConfig = exports.
|
|
10
|
-
exports.reportInlineTags = exports.normalizeTags = exports.LAST_UPDATE_FALLBACK = exports.readLastUpdateData = exports.getLastUpdate = exports.getGitLastUpdate = exports.flattenRoutes = exports.askPreferredLanguage = exports.escapeRegexp = exports.isUnlisted = exports.isDraft = exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.readDataFile = exports.getDataFilePath = exports.loadFreshModule = exports.getWebpackLoaderCompilerName = exports.getFileLoaderUtils = exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.globTranslatableSourceFiles = exports.safeGlobby = exports.GlobExcludeDefault = exports.Globby = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePathToRelativePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = exports.resolveMarkdownLinkPathname = exports.writeMarkdownHeadingId = exports.parseMarkdownFile =
|
|
9
|
+
exports.parseMarkdownContentTitle = exports.DEFAULT_PARSE_FRONT_MATTER = exports.createExcerpt = exports.admonitionTitleToDirectiveLabel = exports.unwrapMdxCodeBlocks = exports.escapeMarkdownHeadingIds = exports.parseMarkdownHeadingId = exports.getTagVisibility = exports.groupTaggedItems = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.serializeURLPath = exports.toURLPath = exports.parseURLOrPath = exports.parseLocalURLPath = exports.parseURLPath = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.getLocaleConfig = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.FileNotTrackedError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.CODE_TRANSLATIONS_FILE_NAME = exports.DEFAULT_I18N_DIR_NAME = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.DEFAULT_STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.DOCUSAURUS_VERSION = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
|
|
10
|
+
exports.reportInlineTags = exports.normalizeTags = exports.LAST_UPDATE_FALLBACK = exports.readLastUpdateData = exports.getLastUpdate = exports.getGitLastUpdate = exports.flattenRoutes = exports.askPreferredLanguage = exports.escapeRegexp = exports.isUnlisted = exports.isDraft = exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.readDataFile = exports.getDataFilePath = exports.loadFreshModule = exports.getWebpackLoaderCompilerName = exports.getFileLoaderUtils = exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.globTranslatableSourceFiles = exports.safeGlobby = exports.GlobExcludeDefault = exports.Globby = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePathToRelativePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = exports.resolveMarkdownLinkPathname = exports.writeMarkdownHeadingId = exports.parseMarkdownFile = void 0;
|
|
11
11
|
var constants_1 = require("./constants");
|
|
12
12
|
Object.defineProperty(exports, "NODE_MAJOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MAJOR_VERSION; } });
|
|
13
13
|
Object.defineProperty(exports, "NODE_MINOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MINOR_VERSION; } });
|
|
@@ -36,7 +36,6 @@ var i18nUtils_1 = require("./i18nUtils");
|
|
|
36
36
|
Object.defineProperty(exports, "mergeTranslations", { enumerable: true, get: function () { return i18nUtils_1.mergeTranslations; } });
|
|
37
37
|
Object.defineProperty(exports, "updateTranslationFileMessages", { enumerable: true, get: function () { return i18nUtils_1.updateTranslationFileMessages; } });
|
|
38
38
|
Object.defineProperty(exports, "getPluginI18nPath", { enumerable: true, get: function () { return i18nUtils_1.getPluginI18nPath; } });
|
|
39
|
-
Object.defineProperty(exports, "localizePath", { enumerable: true, get: function () { return i18nUtils_1.localizePath; } });
|
|
40
39
|
Object.defineProperty(exports, "getLocaleConfig", { enumerable: true, get: function () { return i18nUtils_1.getLocaleConfig; } });
|
|
41
40
|
var jsUtils_1 = require("./jsUtils");
|
|
42
41
|
Object.defineProperty(exports, "mapAsyncSequential", { enumerable: true, get: function () { return jsUtils_1.mapAsyncSequential; } });
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,yCAiBqB;AAhBnB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,yGAAA,YAAY,OAAA;AACZ,oHAAA,uBAAuB,OAAA;AACvB,0HAAA,6BAA6B,OAAA;AAC7B,uGAAA,UAAU,OAAA;AACV,kHAAA,qBAAqB,OAAA;AACrB,wHAAA,2BAA2B,OAAA;AAC3B,yGAAA,YAAY,OAAA;AACZ,8GAAA,iBAAiB,OAAA;AACjB,qHAAA,wBAAwB,OAAA;AAE1B,yCAAyD;AAAjD,qGAAA,QAAQ,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AACpC,uCAIoB;AAHlB,6GAAA,iB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HAAA,wBAAwB,OAAA;AACxB,wHAAA,uBAAuB,OAAA;AAEzB,mEAA6D;AAArD,iHAAA,OAAO,OAAA;AAAE,oHAAA,UAAU,OAAA;AAC3B,6CAA2C;AAAnC,2GAAA,YAAY,OAAA;AACpB,uCAAgD;AAAxC,gHAAA,oBAAoB,OAAA;AAC5B,2CAA2C;AAAnC,2GAAA,aAAa,OAAA;AAErB,qDAO2B;AANzB,mHAAA,gBAAgB,OAAA;AAChB,gHAAA,aAAa,OAAA;AACb,qHAAA,kBAAkB,OAAA;AAClB,uHAAA,oBAAoB,OAAA;AAKtB,+BAAuD;AAA/C,qGAAA,aAAa,OAAA;AAAE,wGAAA,gBAAgB,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "3.8.1-canary-
|
|
3
|
+
"version": "3.8.1-canary-6374",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "3.8.1-canary-
|
|
22
|
-
"@docusaurus/types": "3.8.1-canary-
|
|
23
|
-
"@docusaurus/utils-common": "3.8.1-canary-
|
|
21
|
+
"@docusaurus/logger": "3.8.1-canary-6374",
|
|
22
|
+
"@docusaurus/types": "3.8.1-canary-6374",
|
|
23
|
+
"@docusaurus/utils-common": "3.8.1-canary-6374",
|
|
24
24
|
"escape-string-regexp": "^4.0.0",
|
|
25
25
|
"execa": "5.1.1",
|
|
26
26
|
"file-loader": "^6.2.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"dedent": "^0.7.0",
|
|
52
52
|
"tmp-promise": "^3.0.3"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "d7c2ad4c6a14ff1185b4ee7bef89cd56c15d3869"
|
|
55
55
|
}
|
package/src/i18nUtils.ts
CHANGED
|
@@ -9,7 +9,6 @@ import path from 'path';
|
|
|
9
9
|
import _ from 'lodash';
|
|
10
10
|
import logger from '@docusaurus/logger';
|
|
11
11
|
import {DEFAULT_PLUGIN_ID} from './constants';
|
|
12
|
-
import {normalizeUrl} from './urlUtils';
|
|
13
12
|
import type {
|
|
14
13
|
TranslationFileContent,
|
|
15
14
|
TranslationFile,
|
|
@@ -67,54 +66,6 @@ export function getPluginI18nPath({
|
|
|
67
66
|
);
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
/**
|
|
71
|
-
* Takes a path and returns a localized a version (which is basically `path +
|
|
72
|
-
* i18n.currentLocale`).
|
|
73
|
-
*
|
|
74
|
-
* This is used to resolve the `outDir` and `baseUrl` of each locale; it is NOT
|
|
75
|
-
* used to determine plugin localization file locations.
|
|
76
|
-
*/
|
|
77
|
-
export function localizePath({
|
|
78
|
-
pathType,
|
|
79
|
-
path: originalPath,
|
|
80
|
-
i18n,
|
|
81
|
-
options = {},
|
|
82
|
-
}: {
|
|
83
|
-
/**
|
|
84
|
-
* FS paths will treat Windows specially; URL paths will always have a
|
|
85
|
-
* trailing slash to make it a valid base URL.
|
|
86
|
-
*/
|
|
87
|
-
pathType: 'fs' | 'url';
|
|
88
|
-
/** The path, URL or file path, to be localized. */
|
|
89
|
-
path: string;
|
|
90
|
-
/** The current i18n context. */
|
|
91
|
-
i18n: I18n;
|
|
92
|
-
options?: {
|
|
93
|
-
/**
|
|
94
|
-
* By default, we don't localize the path of defaultLocale. This option
|
|
95
|
-
* would override that behavior. Setting `false` is useful for `yarn build
|
|
96
|
-
* -l zh-Hans` to always emit into the root build directory.
|
|
97
|
-
*/
|
|
98
|
-
localizePath?: boolean;
|
|
99
|
-
};
|
|
100
|
-
}): string {
|
|
101
|
-
const shouldLocalizePath: boolean =
|
|
102
|
-
options.localizePath ?? i18n.currentLocale !== i18n.defaultLocale;
|
|
103
|
-
|
|
104
|
-
if (!shouldLocalizePath) {
|
|
105
|
-
return originalPath;
|
|
106
|
-
}
|
|
107
|
-
// FS paths need special care, for Windows support. Note: we don't use the
|
|
108
|
-
// locale config's `path` here, because this function is used for resolving
|
|
109
|
-
// outDir, which must be the same as baseUrl. When we have the baseUrl config,
|
|
110
|
-
// we need to sync the two.
|
|
111
|
-
if (pathType === 'fs') {
|
|
112
|
-
return path.join(originalPath, i18n.currentLocale);
|
|
113
|
-
}
|
|
114
|
-
// Url paths; add a trailing slash so it's a valid base URL
|
|
115
|
-
return normalizeUrl([originalPath, i18n.currentLocale, '/']);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
69
|
// TODO we may extract this to a separate package
|
|
119
70
|
// we want to use it on the frontend too
|
|
120
71
|
// but "docusaurus-utils-common" (agnostic utils) is not an ideal place since
|