@rushstack/webpack4-localization-plugin 0.14.5
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/LICENSE +24 -0
- package/README.md +292 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/webpack4-localization-plugin.d.ts +324 -0
- package/lib/AssetProcessor.d.ts +36 -0
- package/lib/AssetProcessor.d.ts.map +1 -0
- package/lib/AssetProcessor.js +306 -0
- package/lib/AssetProcessor.js.map +1 -0
- package/lib/LocalizationPlugin.d.ts +77 -0
- package/lib/LocalizationPlugin.d.ts.map +1 -0
- package/lib/LocalizationPlugin.js +597 -0
- package/lib/LocalizationPlugin.js.map +1 -0
- package/lib/WebpackConfigurationUpdater.d.ts +22 -0
- package/lib/WebpackConfigurationUpdater.d.ts.map +1 -0
- package/lib/WebpackConfigurationUpdater.js +136 -0
- package/lib/WebpackConfigurationUpdater.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces.d.ts +219 -0
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/interfaces.js +5 -0
- package/lib/interfaces.js.map +1 -0
- package/lib/loaders/InPlaceLocFileLoader.d.ts +4 -0
- package/lib/loaders/InPlaceLocFileLoader.d.ts.map +1 -0
- package/lib/loaders/InPlaceLocFileLoader.js +17 -0
- package/lib/loaders/InPlaceLocFileLoader.js.map +1 -0
- package/lib/loaders/LoaderFactory.d.ts +13 -0
- package/lib/loaders/LoaderFactory.d.ts.map +1 -0
- package/lib/loaders/LoaderFactory.js +41 -0
- package/lib/loaders/LoaderFactory.js.map +1 -0
- package/lib/loaders/LocLoader.d.ts +9 -0
- package/lib/loaders/LocLoader.d.ts.map +1 -0
- package/lib/loaders/LocLoader.js +36 -0
- package/lib/loaders/LocLoader.js.map +1 -0
- package/lib/utilities/Constants.d.ts +14 -0
- package/lib/utilities/Constants.d.ts.map +1 -0
- package/lib/utilities/Constants.js +44 -0
- package/lib/utilities/Constants.js.map +1 -0
- package/lib/utilities/EntityMarker.d.ts +13 -0
- package/lib/utilities/EntityMarker.d.ts.map +1 -0
- package/lib/utilities/EntityMarker.js +19 -0
- package/lib/utilities/EntityMarker.js.map +1 -0
- package/lib/utilities/LoaderTerminalProvider.d.ts +6 -0
- package/lib/utilities/LoaderTerminalProvider.d.ts.map +1 -0
- package/lib/utilities/LoaderTerminalProvider.js +28 -0
- package/lib/utilities/LoaderTerminalProvider.js.map +1 -0
- package/lib/webpackInterfaces.d.ts +10 -0
- package/lib/webpackInterfaces.d.ts.map +1 -0
- package/lib/webpackInterfaces.js +5 -0
- package/lib/webpackInterfaces.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.loaderFactory = void 0;
|
|
29
|
+
const loaderUtils = __importStar(require("loader-utils"));
|
|
30
|
+
function loaderFactory(innerLoader) {
|
|
31
|
+
return function (content) {
|
|
32
|
+
const options = loaderUtils.getOptions(this);
|
|
33
|
+
if (typeof content !== 'string') {
|
|
34
|
+
content = content.toString();
|
|
35
|
+
}
|
|
36
|
+
const resultObject = innerLoader.call(this, this.resourcePath, content, options);
|
|
37
|
+
return JSON.stringify(resultObject);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.loaderFactory = loaderFactory;
|
|
41
|
+
//# sourceMappingURL=LoaderFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoaderFactory.js","sourceRoot":"","sources":["../../src/loaders/LoaderFactory.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAG3D,0DAA4C;AAc5C,SAAgB,aAAa,CAC3B,WAAuF;IAEvF,OAAO,UAAsC,OAAwB;QACnE,MAAM,OAAO,GAAa,WAAW,CAAC,UAAU,CAAC,IAAI,CAAa,CAAC;QACnE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;SAC9B;QAED,MAAM,YAAY,GAAkB,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAChG,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC;AAZD,sCAYC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { loader } from 'webpack';\nimport * as loaderUtils from 'loader-utils';\nimport { NewlineKind } from '@rushstack/node-core-library';\nimport type { IgnoreStringFunction } from '@rushstack/localization-utilities';\n\nexport interface IBaseLoaderOptions {\n resxNewlineNormalization: NewlineKind | undefined;\n ignoreMissingResxComments: boolean | undefined;\n ignoreString: IgnoreStringFunction | undefined;\n}\n\nexport interface ILoaderResult {\n [stringName: string]: string;\n}\n\nexport function loaderFactory<TOptions extends IBaseLoaderOptions>(\n innerLoader: (locFilePath: string, content: string, options: TOptions) => ILoaderResult\n): loader.Loader {\n return function (this: loader.LoaderContext, content: string | Buffer): string {\n const options: TOptions = loaderUtils.getOptions(this) as TOptions;\n if (typeof content !== 'string') {\n content = content.toString();\n }\n\n const resultObject: ILoaderResult = innerLoader.call(this, this.resourcePath, content, options);\n return JSON.stringify(resultObject);\n };\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { loader } from 'webpack';
|
|
2
|
+
import { LocalizationPlugin } from '../LocalizationPlugin';
|
|
3
|
+
import { IBaseLoaderOptions } from './LoaderFactory';
|
|
4
|
+
export interface ILocLoaderOptions extends IBaseLoaderOptions {
|
|
5
|
+
pluginInstance: LocalizationPlugin;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: loader.Loader;
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=LocLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocLoader.d.ts","sourceRoot":"","sources":["../../src/loaders/LocLoader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAiB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAIpE,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,cAAc,EAAE,kBAAkB,CAAC;CACpC;;AAED,wBAyCG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
6
|
+
const localization_utilities_1 = require("@rushstack/localization-utilities");
|
|
7
|
+
const LoaderFactory_1 = require("./LoaderFactory");
|
|
8
|
+
const EntityMarker_1 = require("../utilities/EntityMarker");
|
|
9
|
+
const LoaderTerminalProvider_1 = require("../utilities/LoaderTerminalProvider");
|
|
10
|
+
exports.default = (0, LoaderFactory_1.loaderFactory)(function (locFilePath, content, options) {
|
|
11
|
+
const { pluginInstance } = options;
|
|
12
|
+
const terminal = new node_core_library_1.Terminal(LoaderTerminalProvider_1.LoaderTerminalProvider.getTerminalProviderForLoader(this));
|
|
13
|
+
const locFileData = (0, localization_utilities_1.parseLocFile)(Object.assign(Object.assign({}, options), { content,
|
|
14
|
+
terminal, filePath: locFilePath }));
|
|
15
|
+
const { additionalLoadedFilePaths, errors } = pluginInstance.addDefaultLocFile(terminal, locFilePath, locFileData);
|
|
16
|
+
for (const additionalFile of additionalLoadedFilePaths) {
|
|
17
|
+
this.dependency(additionalFile);
|
|
18
|
+
}
|
|
19
|
+
for (const error of errors) {
|
|
20
|
+
this.emitError(error);
|
|
21
|
+
}
|
|
22
|
+
const resultObject = {};
|
|
23
|
+
// eslint-disable-next-line guard-for-in
|
|
24
|
+
for (const stringName in locFileData) {
|
|
25
|
+
const stringKey = `${locFilePath}?${stringName}`;
|
|
26
|
+
if (pluginInstance.stringKeys.has(stringKey)) {
|
|
27
|
+
resultObject[stringName] = pluginInstance.stringKeys.get(stringKey).value;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new Error(`Unexpected - missing placeholder for string key "${stringKey}"`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
EntityMarker_1.EntityMarker.markEntity(this._module, true);
|
|
34
|
+
return resultObject;
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=LocLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocLoader.js","sourceRoot":"","sources":["../../src/loaders/LocLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,oEAAwD;AACxD,8EAAoF;AAGpF,mDAAoE;AACpE,4DAAyD;AACzD,gFAA6E;AAM7E,kBAAe,IAAA,6BAAa,EAAC,UAE3B,WAAmB,EACnB,OAAe,EACf,OAA0B;IAE1B,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,QAAQ,GAAa,IAAI,4BAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,CAAC;IACnG,MAAM,WAAW,GAAsB,IAAA,qCAAY,kCAC9C,OAAO,KACV,OAAO;QACP,QAAQ,EACR,QAAQ,EAAE,WAAW,IACrB,CAAC;IACH,MAAM,EAAE,yBAAyB,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,iBAAiB,CAC5E,QAAQ,EACR,WAAW,EACX,WAAW,CACZ,CAAC;IACF,KAAK,MAAM,cAAc,IAAI,yBAAyB,EAAE;QACtD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;KACjC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACvB;IAED,MAAM,YAAY,GAAqC,EAAE,CAAC;IAC1D,wCAAwC;IACxC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,SAAS,GAAW,GAAG,WAAW,IAAI,UAAU,EAAE,CAAC;QACzD,IAAI,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC5C,YAAY,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,KAAK,CAAC;SAC5E;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,oDAAoD,SAAS,GAAG,CAAC,CAAC;SACnF;KACF;IAED,2BAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAE5C,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { loader } from 'webpack';\nimport { Terminal } from '@rushstack/node-core-library';\nimport { ILocalizationFile, parseLocFile } from '@rushstack/localization-utilities';\n\nimport { LocalizationPlugin } from '../LocalizationPlugin';\nimport { loaderFactory, IBaseLoaderOptions } from './LoaderFactory';\nimport { EntityMarker } from '../utilities/EntityMarker';\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\n\nexport interface ILocLoaderOptions extends IBaseLoaderOptions {\n pluginInstance: LocalizationPlugin;\n}\n\nexport default loaderFactory(function (\n this: loader.LoaderContext,\n locFilePath: string,\n content: string,\n options: ILocLoaderOptions\n) {\n const { pluginInstance } = options;\n const terminal: Terminal = new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(this));\n const locFileData: ILocalizationFile = parseLocFile({\n ...options,\n content,\n terminal,\n filePath: locFilePath\n });\n const { additionalLoadedFilePaths, errors } = pluginInstance.addDefaultLocFile(\n terminal,\n locFilePath,\n locFileData\n );\n for (const additionalFile of additionalLoadedFilePaths) {\n this.dependency(additionalFile);\n }\n\n for (const error of errors) {\n this.emitError(error);\n }\n\n const resultObject: { [stringName: string]: string } = {};\n // eslint-disable-next-line guard-for-in\n for (const stringName in locFileData) {\n const stringKey: string = `${locFilePath}?${stringName}`;\n if (pluginInstance.stringKeys.has(stringKey)) {\n resultObject[stringName] = pluginInstance.stringKeys.get(stringKey)!.value;\n } else {\n throw new Error(`Unexpected - missing placeholder for string key \"${stringKey}\"`);\n }\n }\n\n EntityMarker.markEntity(this._module, true);\n\n return resultObject;\n});\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class Constants {
|
|
2
|
+
static LOCALE_FILENAME_TOKEN: string;
|
|
3
|
+
static LOCALE_FILENAME_TOKEN_REGEX: RegExp;
|
|
4
|
+
static NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN: string;
|
|
5
|
+
static NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX: RegExp;
|
|
6
|
+
static STRING_PLACEHOLDER_PREFIX: string;
|
|
7
|
+
static RESOURCE_FILE_NAME_REGEXP: RegExp;
|
|
8
|
+
static STRING_PLACEHOLDER_LABEL: string;
|
|
9
|
+
static LOCALE_NAME_PLACEHOLDER_LABEL: string;
|
|
10
|
+
static JSONP_PLACEHOLDER_LABEL: string;
|
|
11
|
+
static LOCALE_NAME_PLACEHOLDER: string;
|
|
12
|
+
static JSONP_PLACEHOLDER: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../src/utilities/Constants.ts"],"names":[],"mappings":"AAKA,qBAAa,SAAS;IACpB,OAAc,qBAAqB,EAAE,MAAM,CAAc;IACzD,OAAc,2BAA2B,EAAE,MAAM,CAG/C;IACF,OAAc,mCAAmC,EAAE,MAAM,CAAsB;IAC/E,OAAc,yCAAyC,EAAE,MAAM,CAG7D;IACF,OAAc,yBAAyB,EAAE,MAAM,CAA4D;IAE3G,OAAc,yBAAyB,EAAE,MAAM,CAA6C;IAE5F,OAAc,wBAAwB,EAAE,MAAM,CAAO;IACrD,OAAc,6BAA6B,EAAE,MAAM,CAAO;IAC1D,OAAc,uBAAuB,EAAE,MAAM,CAAO;IAEpD,OAAc,uBAAuB,EAAE,MAAM,CAA0F;IACvI,OAAc,iBAAiB,EAAE,MAAM,CAA6F;CACrI"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.Constants = void 0;
|
|
29
|
+
const lodash = __importStar(require("lodash"));
|
|
30
|
+
class Constants {
|
|
31
|
+
}
|
|
32
|
+
exports.Constants = Constants;
|
|
33
|
+
Constants.LOCALE_FILENAME_TOKEN = '[locale]';
|
|
34
|
+
Constants.LOCALE_FILENAME_TOKEN_REGEX = new RegExp(lodash.escapeRegExp(Constants.LOCALE_FILENAME_TOKEN), 'gi');
|
|
35
|
+
Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN = '[no-locale-file]';
|
|
36
|
+
Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX = new RegExp(lodash.escapeRegExp(Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN), 'gi');
|
|
37
|
+
Constants.STRING_PLACEHOLDER_PREFIX = '_LOCALIZED_STRING_f12dy0i7_n4bo_dqwj_39gf_sasqehjmihz9';
|
|
38
|
+
Constants.RESOURCE_FILE_NAME_REGEXP = /\.(resx|resx\.json|loc\.json|resjson)$/i;
|
|
39
|
+
Constants.STRING_PLACEHOLDER_LABEL = 'A';
|
|
40
|
+
Constants.LOCALE_NAME_PLACEHOLDER_LABEL = 'B';
|
|
41
|
+
Constants.JSONP_PLACEHOLDER_LABEL = 'C';
|
|
42
|
+
Constants.LOCALE_NAME_PLACEHOLDER = `${Constants.STRING_PLACEHOLDER_PREFIX}__${Constants.LOCALE_NAME_PLACEHOLDER_LABEL}_0`;
|
|
43
|
+
Constants.JSONP_PLACEHOLDER = `${Constants.STRING_PLACEHOLDER_PREFIX}__${Constants.JSONP_PLACEHOLDER_LABEL}+chunkId+_0`;
|
|
44
|
+
//# sourceMappingURL=Constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/utilities/Constants.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,MAAa,SAAS;;AAAtB,8BAqBC;AApBe,+BAAqB,GAAW,UAAU,CAAC;AAC3C,qCAA2B,GAAW,IAAI,MAAM,CAC5D,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,qBAAqB,CAAC,EACpD,IAAI,CACL,CAAC;AACY,6CAAmC,GAAW,kBAAkB,CAAC;AACjE,mDAAyC,GAAW,IAAI,MAAM,CAC1E,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,mCAAmC,CAAC,EAClE,IAAI,CACL,CAAC;AACY,mCAAyB,GAAW,wDAAwD,CAAC;AAE7F,mCAAyB,GAAW,yCAAyC,CAAC;AAE9E,kCAAwB,GAAW,GAAG,CAAC;AACvC,uCAA6B,GAAW,GAAG,CAAC;AAC5C,iCAAuB,GAAW,GAAG,CAAC;AAEtC,iCAAuB,GAAW,GAAG,SAAS,CAAC,yBAAyB,KAAK,SAAS,CAAC,6BAA6B,IAAI,CAAC;AACzH,2BAAiB,GAAW,GAAG,SAAS,CAAC,yBAAyB,KAAK,SAAS,CAAC,uBAAuB,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as lodash from 'lodash';\n\nexport class Constants {\n public static LOCALE_FILENAME_TOKEN: string = '[locale]';\n public static LOCALE_FILENAME_TOKEN_REGEX: RegExp = new RegExp(\n lodash.escapeRegExp(Constants.LOCALE_FILENAME_TOKEN),\n 'gi'\n );\n public static NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN: string = '[no-locale-file]';\n public static NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX: RegExp = new RegExp(\n lodash.escapeRegExp(Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN),\n 'gi'\n );\n public static STRING_PLACEHOLDER_PREFIX: string = '_LOCALIZED_STRING_f12dy0i7_n4bo_dqwj_39gf_sasqehjmihz9';\n\n public static RESOURCE_FILE_NAME_REGEXP: RegExp = /\\.(resx|resx\\.json|loc\\.json|resjson)$/i;\n\n public static STRING_PLACEHOLDER_LABEL: string = 'A';\n public static LOCALE_NAME_PLACEHOLDER_LABEL: string = 'B';\n public static JSONP_PLACEHOLDER_LABEL: string = 'C';\n\n public static LOCALE_NAME_PLACEHOLDER: string = `${Constants.STRING_PLACEHOLDER_PREFIX}__${Constants.LOCALE_NAME_PLACEHOLDER_LABEL}_0`;\n public static JSONP_PLACEHOLDER: string = `${Constants.STRING_PLACEHOLDER_PREFIX}__${Constants.JSONP_PLACEHOLDER_LABEL}+chunkId+_0`;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const LABEL: unique symbol;
|
|
2
|
+
export interface IMarkable {
|
|
3
|
+
[LABEL]: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Use the functions on this class to mark webpack entities that contain localized resources.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EntityMarker {
|
|
9
|
+
static markEntity<TModule>(module: TModule, value: boolean): void;
|
|
10
|
+
static getMark<TModule>(module: TModule): boolean | undefined;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=EntityMarker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityMarker.d.ts","sourceRoot":"","sources":["../../src/utilities/EntityMarker.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,KAAK,EAAE,OAAO,MAAoC,CAAC;AAEzD,MAAM,WAAW,SAAS;IACxB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,YAAY;WACT,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;WAI1D,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;CAGrE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.EntityMarker = void 0;
|
|
6
|
+
const LABEL = Symbol('loc-plugin-marked');
|
|
7
|
+
/**
|
|
8
|
+
* Use the functions on this class to mark webpack entities that contain localized resources.
|
|
9
|
+
*/
|
|
10
|
+
class EntityMarker {
|
|
11
|
+
static markEntity(module, value) {
|
|
12
|
+
module[LABEL] = value;
|
|
13
|
+
}
|
|
14
|
+
static getMark(module) {
|
|
15
|
+
return module[LABEL];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.EntityMarker = EntityMarker;
|
|
19
|
+
//# sourceMappingURL=EntityMarker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityMarker.js","sourceRoot":"","sources":["../../src/utilities/EntityMarker.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,MAAM,KAAK,GAAkB,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAMzD;;GAEG;AACH,MAAa,YAAY;IAChB,MAAM,CAAC,UAAU,CAAU,MAAe,EAAE,KAAc;QAC9D,MAA+B,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IAClD,CAAC;IAEM,MAAM,CAAC,OAAO,CAAU,MAAe;QAC5C,OAAQ,MAA+B,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF;AARD,oCAQC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nconst LABEL: unique symbol = Symbol('loc-plugin-marked');\n\nexport interface IMarkable {\n [LABEL]: boolean;\n}\n\n/**\n * Use the functions on this class to mark webpack entities that contain localized resources.\n */\nexport class EntityMarker {\n public static markEntity<TModule>(module: TModule, value: boolean): void {\n (module as unknown as IMarkable)[LABEL] = value;\n }\n\n public static getMark<TModule>(module: TModule): boolean | undefined {\n return (module as unknown as IMarkable)[LABEL];\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as webpack from 'webpack';
|
|
2
|
+
import { ITerminalProvider } from '@rushstack/node-core-library';
|
|
3
|
+
export declare class LoaderTerminalProvider {
|
|
4
|
+
static getTerminalProviderForLoader(loaderContext: webpack.loader.LoaderContext): ITerminalProvider;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=LoaderTerminalProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoaderTerminalProvider.d.ts","sourceRoot":"","sources":["../../src/utilities/LoaderTerminalProvider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA4B,MAAM,8BAA8B,CAAC;AAE3F,qBAAa,sBAAsB;WACnB,4BAA4B,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,GAAG,iBAAiB;CAmB3G"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.LoaderTerminalProvider = void 0;
|
|
6
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
7
|
+
class LoaderTerminalProvider {
|
|
8
|
+
static getTerminalProviderForLoader(loaderContext) {
|
|
9
|
+
return {
|
|
10
|
+
supportsColor: false,
|
|
11
|
+
eolCharacter: '\n',
|
|
12
|
+
write: (data, severity) => {
|
|
13
|
+
switch (severity) {
|
|
14
|
+
case node_core_library_1.TerminalProviderSeverity.error: {
|
|
15
|
+
loaderContext.emitError(new Error(data));
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
case node_core_library_1.TerminalProviderSeverity.warning: {
|
|
19
|
+
loaderContext.emitWarning(new Error(data));
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.LoaderTerminalProvider = LoaderTerminalProvider;
|
|
28
|
+
//# sourceMappingURL=LoaderTerminalProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoaderTerminalProvider.js","sourceRoot":"","sources":["../../src/utilities/LoaderTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAA2F;AAE3F,MAAa,sBAAsB;IAC1B,MAAM,CAAC,4BAA4B,CAAC,aAA2C;QACpF,OAAO;YACL,aAAa,EAAE,KAAK;YACpB,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,CAAC,IAAY,EAAE,QAAkC,EAAE,EAAE;gBAC1D,QAAQ,QAAQ,EAAE;oBAChB,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC;wBACnC,aAAa,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;wBACzC,MAAM;qBACP;oBAED,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC;wBACrC,aAAa,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;wBAC3C,MAAM;qBACP;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AApBD,wDAoBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as webpack from 'webpack';\nimport { ITerminalProvider, TerminalProviderSeverity } from '@rushstack/node-core-library';\n\nexport class LoaderTerminalProvider {\n public static getTerminalProviderForLoader(loaderContext: webpack.loader.LoaderContext): ITerminalProvider {\n return {\n supportsColor: false,\n eolCharacter: '\\n',\n write: (data: string, severity: TerminalProviderSeverity) => {\n switch (severity) {\n case TerminalProviderSeverity.error: {\n loaderContext.emitError(new Error(data));\n break;\n }\n\n case TerminalProviderSeverity.warning: {\n loaderContext.emitWarning(new Error(data));\n break;\n }\n }\n }\n };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpackInterfaces.d.ts","sourceRoot":"","sources":["../src/webpackInterfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,OAAO,CAAC,WAAW,CAAC,KAAK;IACvE,cAAc,CAAC,EAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAC/C"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
|
+
// See LICENSE in the project root for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
//# sourceMappingURL=webpackInterfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpackInterfaces.js","sourceRoot":"","sources":["../src/webpackInterfaces.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as webpack from 'webpack';\n\n/**\n * @public\n */\nexport interface ILocalizedWebpackChunk extends webpack.compilation.Chunk {\n localizedFiles?: { [locale: string]: string };\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rushstack/webpack4-localization-plugin",
|
|
3
|
+
"version": "0.14.5",
|
|
4
|
+
"description": "This plugin facilitates localization with Webpack.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"typings": "dist/webpack4-localization-plugin.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/microsoft/rushstack.git",
|
|
11
|
+
"directory": "webpack/localization-plugin-4"
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@rushstack/set-webpack-public-path-plugin": "^3.3.42",
|
|
15
|
+
"@types/webpack": "^4.39.0",
|
|
16
|
+
"webpack": "^4.31.0"
|
|
17
|
+
},
|
|
18
|
+
"peerDependenciesMeta": {
|
|
19
|
+
"@rushstack/set-webpack-public-path-plugin": {
|
|
20
|
+
"optional": true
|
|
21
|
+
},
|
|
22
|
+
"@types/webpack": {
|
|
23
|
+
"optional": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@rushstack/localization-utilities": "0.7.2",
|
|
28
|
+
"@rushstack/node-core-library": "3.45.7",
|
|
29
|
+
"@types/node": "12.20.24",
|
|
30
|
+
"@types/tapable": "1.0.6",
|
|
31
|
+
"loader-utils": "~1.1.0",
|
|
32
|
+
"lodash": "~4.17.15",
|
|
33
|
+
"minimatch": "~3.0.3"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@rushstack/eslint-config": "2.6.1",
|
|
37
|
+
"@rushstack/heft": "0.45.9",
|
|
38
|
+
"@rushstack/heft-node-rig": "1.9.10",
|
|
39
|
+
"@rushstack/set-webpack-public-path-plugin": "3.3.42",
|
|
40
|
+
"@types/loader-utils": "1.1.3",
|
|
41
|
+
"@types/lodash": "4.14.116",
|
|
42
|
+
"@types/minimatch": "3.0.5",
|
|
43
|
+
"@types/webpack": "4.41.32",
|
|
44
|
+
"webpack": "~4.44.2"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "heft build --clean",
|
|
48
|
+
"_phase:build": "heft build --clean"
|
|
49
|
+
},
|
|
50
|
+
"readme": "# @rushstack/webpack4-localization-plugin\n\n## Installation\n\n`npm install @rushstack/webpack4-localization-plugin --save-dev`\n\n## Overview\n\nThis Webpack plugin produces bundles that have multiple locales' variants of strings embedded. It also\nhas out-of-box support for RESX files in addition to JSON strings files (with the extension `.loc.json`), including\nsupport for generating typings.\n\n### Example Plugin Usage\n\nThere are three example projects in this repository that make use of this plugin:\n\n- [Project 1](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-01)\n - This project contains two webpack entrypoints (one with an async chunk, one without), without any localized\n resources\n - The output is a single, non-localized variant\n- [Project 2](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-02)\n - This project contains three webpack entrypoints:\n - [`indexA.ts`](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-02/src/indexA.ts)\n directly references two `.loc.json` files and one `.resx` file, and dynamically imports an async chunk with\n localized data, and an async chunk without localized data\n - [`indexB.ts`](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-02/src/indexB.ts)\n directly references two `.loc.json` files\n - [`indexC.ts`](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-02/src/indexC.ts)\n directly references no localized resources, and dynamically imports an async chunk without localized data\n - The webpack config contains and references Spanish translations for most of the English strings in the resource files\n - The output contains English, Spanish, and \"passthrough\" localized variants of files that contain\n localized data, and a non-localized variant of the files that do not contain localized data\n- [Project 3](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-03)\n - This project contains four webpack entrypoints:\n - [`indexA.ts`](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-03/src/indexA.ts)\n directly references one `.loc.json` file, one `.resx.json` file, one `.resx` file, and one `.resjson` file, and dynamically imports an async chunk with\n localized data, and an async chunk without localized data\n - [`indexB.ts`](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-03/src/indexB.ts)\n directly references one `.loc.json` file and one `.resx.json` file\n - [`indexC.ts`](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-03/src/indexC.ts)\n directly references no localized resources, and dynamically imports an async chunk with localized data\n - [`indexD.ts`](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-03/src/indexD.ts)\n directly references no localized resources, and dynamically imports an async chunk without localized data\n - The webpack config contains or references Spanish translations for some of the English strings in the resource files\n - The output contains English, Spanish, \"passthrough,\" and two pseudo-localized variants of files that contain\n localized data, and a non-localized variant of the files that do not contain localized data\n\n### `.resx` vs `.loc.json` vs `.resjson`\n\n[`.resx`](https://docs.microsoft.com/en-us/dotnet/framework/resources/creating-resource-files-for-desktop-apps#resources-in-resx-files)\nis an XML format for resource data. It is primarily used in .NET development, and it is supported by\nsome translation services. See an example of a `.resx` file\n[here](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-02/src/strings5.resx).\nNote that the `<xsd:schema>` and `<resheader>` elements are not required. Also note that although the\n`.resx` supports many different types of localized data including strings and binary data, **only strings**\nare supported by this plugin.\n\n`.loc.json` is a very simple `JSON` schema for specifying localized string and translator comments.\nSee an example of a `.loc.json` file\n[here](https://github.com/microsoft/rushstack/tree/main/build-tests/localization-plugin-test-02/src/strings3.loc.json).\n\n`.resjson` is another simple `JSON` schema for specifying localized string and translator comments.\nSee [here](https://lingohub.com/developers/resource-files/resjson-localization) for documentation on `.resjson`\n\nFor most projects, `.loc.json` is a simpler format to use. However for large projects, projects that already use\ntranslation services that support `.resx`, or engineers who are already experienced .NET developers, `.resx`\nmay be more convenient.\n\n# Plugin\n\nTo use the plugin, add it to the `plugins` array of your Webpack config. For example:\n\n```JavaScript\nimport { LocalizationPlugin } from '@rushstack/webpack4-localization-plugin';\n\n{\n plugins: [\n new LocalizationPlugin( /* options */ )\n ]\n}\n```\n\n***A note about the dev server:*** When Webpack is being run by the Webpack dev server, this plugin pipes\nthe strings in the loc files in the source (the `.loc.json` and the `.resx` files) to the output without\nany translations.\n\n## Options\n\n### `localizedData = { }`\n\n#### `localizedData.defaultLocale = { }`\n\nThis option has a required property (`localeName`), to specify the name of the locale used in the\n`.resx` and `.loc.json` files in the source.\n\n##### `localizedData.defaultLocale.fillMissingTranslationStrings = true | false`\n\nIf this option is set to `true`, strings that are missing from `localizedData.translatedStrings` will be\nprovided by the default locale (the strings in the `.resx` and `.loc.json` files in the source). If\nthis option is unset or set to `false`, an error will be emitted if a string is missing from\n`localizedData.translatedStrings`.\n\n#### `localizedData.translatedStrings = { }`\n\nThis option is used to specify the localization data to be used in the build. This object has the following\nstructure:\n\n- Locale name\n - Compilation context-relative or absolute localization file path\n - Translated strings\n\nFor example:\n\n```JavaScript\ntranslatedStrings: {\n \"en-us\": {\n \"./src/strings1.loc.json\": {\n \"string1\": \"the first string\"\n }\n },\n \"es-es\": {\n \"./src/strings1.loc.json\": {\n \"string1\": \"la primera cadena\"\n }\n }\n}\n```\n\nAlternatively, instead of directly specifying the translations, a path to a translated resource file can be\nspecified. For example:\n\n```JavaScript\ntranslatedStrings: {\n \"en-us\": {\n \"./src/strings1.loc.json\": \"./localization/en-us/strings1.loc.json\"\n },\n \"es-es\": {\n \"./src/strings1.loc.json\": \"./localization/es-es/strings1.loc.json\"\n }\n}\n```\n\n#### `localizedData.resolveMissingTranslatedStrings = (locales: string[], filePath: string) => { ... }`\n\nThis optional option can be used to resolve translated data that is missing from data that is provided\nin the `localizedData.translatedStrings` option. Set this option with a function expecting two parameters:\nthe first, an array of locale names, and second, a fully-qualified path to the localized file in source. The\nfunction should return an object with locale names as keys and localized data as values. The localized data\nvalue should either be:\n\n- a string: The absolute path to the translated data in `.resx` or `.loc.json` format\n- an object: An object containing the translated data\n\nNote that these values are the same as the values that can be specified for translations for a localized\nresource in `localizedData.translatedStrings`.\n\nIf the function returns data that is missing locales or individual strings, the plugin will fall back to the\ndefault locale if `localizedData.defaultLocale.fillMissingTranslationStrings` is set to `true`. If\n`localizedData.defaultLocale.fillMissingTranslationStrings` is set to `false`, an error will result.\n\n#### `localizedData.passthroughLocale = { }`\n\nThis option is used to specify how and if a passthrough locale should be generated. A passthrough locale\nis a generated locale in which each string's value is its name. This is useful for debugging and for identifying\ncases where a locale is missing.\n\nThis option takes two optional properties:\n\n##### `localizedData.passthroughLocale.usePassthroughLocale = true | false`\n\nIf `passthroughLocale.usePassthroughLocale` is set to `true`, a passthrough locale will be included in the output.\nBy default, the passthrough locale's name is \"passthrough.\"\n\n##### `localizedData.passthroughLocale.passthroughLocaleName = '...'`\n\nIf `passthroughLocale.usePassthroughLocale` is set to `true`, the \"passthrough\" locale name can be overridden\nby setting a value on `passthroughLocale.passthroughLocaleName`.\n\n#### `localizedData.pseudolocales = { }`\n\nThis option allows pseudolocales to be generated from the strings in the default locale. This option takes\nan option with pseudolocales as keys and options for the\n[pseudolocale package](https://www.npmjs.com/package/pseudolocale) as values.\n\n#### `localizedData.normalizeResxNewlines = 'crlf' | 'lf'`\n\nThis option allows normalization of newlines in RESX files. RESX files are XML, so newlines can be\nspecified by including a newline in the `<value>` element. For files stored on source control systems,\nclones on Windows can end up with CRLF newlines and clones on 'nix operating systems can end up with LF\nnewlines. This option can be used to help make compilations run on different platforms produce the same\nresult.\n\n#### `localizedData.ignoreMissingResxComments = true | false | undefined\n\nIf set to true, do not warn on missing RESX <data> element comments.\n\n### `globsToIgnore = [ ]`\n\nThis option is used to specify `.resx` and `.loc.json` files that should not be processed by this plugin.\nBy default, every `.resx`, `.resx.json`, and `.loc.json` file import is intercepted by this plugin, and an\nerror occurs if translations aren't provided for an intercepted file and the\n`localizedData.defaultLocale.fillMissingTranslationStrings` option is set to falsy, or if the\nfile is in an unexpected format. To avoid an error, specify files that should be ignored by this plugin in\nthis property. This is useful if a dependency uses files with a `.resx`, `.resx.json`, or `.loc.json`\nextension, but are processed in a different way from how this plugin handles localization.\nFor example: `globsToIgnore: [ 'node_modules/some-dependency-name/lib/**/*.loc.json' ]`\n\n### `noStringsLocaleName = '...'`\n\nThe value to replace the `[locale]` token with for chunks without localized strings. Defaults to \"none\"\n\n### `localizationStats = { }`\n\n#### `localizationStats.dropPath = '...'`\n\nThis option is used to designate a path at which a JSON file describing the localized assets produced should be\nwritten. If this property is omitted, the stats file won't be written.\n\nThe file has the following format:\n\n```JSON\n{\n \"entrypoints\": {\n \"<BUNDLE NAME>\": {\n \"localizedAssets\": {\n \"<LOCALE NAME>\": \"<ASSET NAME>\",\n \"<LOCALE NAME>\": \"<ASSET NAME>\"\n }\n },\n \"<BUNDLE NAME>\": {\n \"localizedAssets\": {\n \"<LOCALE NAME>\": \"<ASSET NAME>\",\n \"<LOCALE NAME>\": \"<ASSET NAME>\"\n }\n }\n },\n \"namedChunkGroups\": {\n \"<CHUNK NAME>\": {\n \"localizedAssets\": {\n \"<LOCALE NAME>\": \"<ASSET NAME>\",\n \"<LOCALE NAME>\": \"<ASSET NAME>\"\n }\n },\n \"<CHUNK NAME>\": {\n \"localizedAssets\": {\n \"<LOCALE NAME>\": \"<ASSET NAME>\",\n \"<LOCALE NAME>\": \"<ASSET NAME>\"\n }\n }\n }\n}\n\n```\n\n#### `localizationStats.callback = (stats) => { ... }`\n\nThis option is used to specify a callback to be called with the stats data that would be dropped at\n[`localizationStats.dropPath`](#localizationStats.DropPath--) after compilation completes.\n\n### `typingsOptions = { }`\n\nThis option is used to specify how and if TypeScript typings should be generated for loc files.\n\nIt takes two options:\n\n#### `typingsOptions.generatedTsFolder = '...'`\n\nThis property specifies the folder in which `.d.ts` files for loc files should be dropped. It is recommended\nthat this be a folder parallel to the source folder, specified in addition to the source folder in the\n[`rootDirs` `tsconfig.json` option](https://www.typescriptlang.org/docs/handbook/compiler-options.html).\n**The folder specified by this option is emptied when compilation is started.**\n\nThis property is required if `typingsOptions` is set.\n\n#### `typingsOptions.sourceRoot = '...'`\n\nThis optional property overrides the compiler context for discovery of localization files for which\ntypings should be generated.\n\n#### `typingsOptions.exportAsDefault = true | false`\n\nIf this option is set to `true`, loc modules typings will be exported wrapped in a `default` property. This\nallows strings to be imported by using the `import strings from './strings.loc.json';` syntax instead of\nthe `import { string1 } from './strings.loc.json';` or the `import * as strings from './strings.loc.json';`\nsyntax. This option is not recommended.\n\n## Links\n\n- [CHANGELOG.md](https://github.com/microsoft/rushstack/blob/main/webpack/localization-plugin/CHANGELOG.md) - Find\n out what's new in the latest version\n\n`@rushstack/webpack4-localization-plugin` is part of the [Rush Stack](https://rushstack.io/) family of projects.\n"
|
|
51
|
+
}
|