@rushstack/localization-utilities 0.9.9 → 0.9.10
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 -24
- package/README.md +3 -3
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/LocFileParser.js.map +1 -1
- package/lib/Pseudolocalization.js.map +1 -1
- package/lib/TypingsGenerator.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/parsers/parseLocJson.js.map +1 -1
- package/lib/parsers/parseResJson.js.map +1 -1
- package/lib/parsers/parseResx.js.map +1 -1
- package/lib/schemas/locJson.schema.json +28 -28
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
@rushstack/localization-utilities
|
|
2
|
-
|
|
3
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
|
|
5
|
-
MIT License
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
-
a copy of this software and associated documentation files (the
|
|
9
|
-
"Software"), to deal in the Software without restriction, including
|
|
10
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
-
the following conditions:
|
|
14
|
-
|
|
15
|
-
The above copyright notice and this permission notice shall be
|
|
16
|
-
included in all copies or substantial portions of the Software.
|
|
17
|
-
|
|
18
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
21
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
22
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
23
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
24
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
@rushstack/localization-utilities
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
|
|
5
|
+
MIT License
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
a copy of this software and associated documentation files (the
|
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
+
the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be
|
|
16
|
+
included in all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# @rushstack/localization-utilities
|
|
2
|
-
|
|
3
|
-
This library provides a set of utilities for working with localization files.
|
|
1
|
+
# @rushstack/localization-utilities
|
|
2
|
+
|
|
3
|
+
This library provides a set of utilities for working with localization files.
|
package/dist/tsdoc-metadata.json
CHANGED
package/lib/LocFileParser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocFileParser.js","sourceRoot":"","sources":["../src/LocFileParser.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,yDAAsD;AACtD,yDAAsD;AACtD,mDAA4E;AAoB5E,MAAM,UAAU,GAAkC,IAAI,GAAG,EAA4B,CAAC;AAEtF,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAC7B,OAAO,MAAM,CAAC;KACf;SAAM,IAAI,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAChD,OAAO,UAAU,CAAC;KACnB;SAAM,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACvC,OAAO,SAAS,CAAC;KAClB;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,EAAE,CAAC,CAAC;KACpE;AACH,CAAC;AAVD,wDAUC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,OAA6B;IACxD,MAAM,EAAE,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,GAAG,OAAO,CAAC;IAEtE,MAAM,YAAY,GAAW,GAAG,OAAO,CAAC,QAAQ,IAAI,MAAM,IAAI,OAAO,CAAC,wBAAwB,IAAI,MAAM,EAAE,CAAC;IAC3G,MAAM,eAAe,GAAiC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACnF,IAAI,eAAe,EAAE;QACnB,IACE,eAAe,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO;YAC3C,eAAe,CAAC,YAAY,KAAK,OAAO,CAAC,YAAY,EACrD;YACA,OAAO,eAAe,CAAC,UAAU,CAAC;SACnC;KACF;IAED,IAAI,UAA6B,CAAC;IAClC,QAAQ,MAAM,EAAE;QACd,KAAK,MAAM,CAAC,CAAC;YACX,UAAU,GAAG,IAAA,qBAAS,EAAC,OAAO,CAAC,CAAC;YAChC,MAAM;SACP;QAED,KAAK,UAAU,CAAC,CAAC;YACf,UAAU,GAAG,IAAA,2BAAY,EAAC,OAAO,CAAC,CAAC;YACnC,MAAM;SACP;QAED,KAAK,SAAS,CAAC,CAAC;YACd,UAAU,GAAG,IAAA,2BAAY,EAAC,OAAO,CAAC,CAAC;YACnC,MAAM;SACP;QAED,OAAO,CAAC,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAC;SAClD;KACF;IAED,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE;QAC3B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU;QACV,YAAY,EAAE,OAAO,CAAC,YAAY;KACnC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC;AA3CD,oCA2CC","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 type { IgnoreStringFunction, ILocalizationFile, IParseFileOptions } from './interfaces';\nimport { parseLocJson } from './parsers/parseLocJson';\nimport { parseResJson } from './parsers/parseResJson';\nimport { type IParseResxOptionsBase, parseResx } from './parsers/parseResx';\n\n/**\n * @public\n */\nexport type ParserKind = 'resx' | 'loc.json' | 'resjson';\n\n/**\n * @public\n */\nexport interface IParseLocFileOptions extends IParseFileOptions, IParseResxOptionsBase {\n parser?: ParserKind;\n}\n\ninterface IParseCacheEntry {\n content: string;\n parsedFile: ILocalizationFile;\n ignoreString: IgnoreStringFunction | undefined;\n}\n\nconst parseCache: Map<string, IParseCacheEntry> = new Map<string, IParseCacheEntry>();\n\nexport function selectParserByFilePath(filePath: string): ParserKind {\n if (/\\.resx$/i.test(filePath)) {\n return 'resx';\n } else if (/\\.(resx|loc)\\.json$/i.test(filePath)) {\n return 'loc.json';\n } else if (/\\.resjson$/i.test(filePath)) {\n return 'resjson';\n } else {\n throw new Error(`Unsupported file extension in file: ${filePath}`);\n }\n}\n\n/**\n * @public\n */\nexport function parseLocFile(options: IParseLocFileOptions): ILocalizationFile {\n const { parser = selectParserByFilePath(options.filePath) } = options;\n\n const fileCacheKey: string = `${options.filePath}?${parser}&${options.resxNewlineNormalization || 'none'}`;\n const parseCacheEntry: IParseCacheEntry | undefined = parseCache.get(fileCacheKey);\n if (parseCacheEntry) {\n if (\n parseCacheEntry.content === options.content &&\n parseCacheEntry.ignoreString === options.ignoreString\n ) {\n return parseCacheEntry.parsedFile;\n }\n }\n\n let parsedFile: ILocalizationFile;\n switch (parser) {\n case 'resx': {\n parsedFile = parseResx(options);\n break;\n }\n\n case 'loc.json': {\n parsedFile = parseLocJson(options);\n break;\n }\n\n case 'resjson': {\n parsedFile = parseResJson(options);\n break;\n }\n\n default: {\n throw new Error(`Unsupported parser: ${parser}`);\n }\n }\n\n parseCache.set(fileCacheKey, {\n content: options.content,\n parsedFile,\n ignoreString: options.ignoreString\n });\n\n return parsedFile;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LocFileParser.js","sourceRoot":"","sources":["../src/LocFileParser.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,yDAAsD;AACtD,yDAAsD;AACtD,mDAA4E;AAoB5E,MAAM,UAAU,GAAkC,IAAI,GAAG,EAA4B,CAAC;AAEtF,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAC7B,OAAO,MAAM,CAAC;KACf;SAAM,IAAI,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAChD,OAAO,UAAU,CAAC;KACnB;SAAM,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACvC,OAAO,SAAS,CAAC;KAClB;SAAM;QACL,MAAM,IAA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) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { IgnoreStringFunction, ILocalizationFile, IParseFileOptions } from './interfaces';\r\nimport { parseLocJson } from './parsers/parseLocJson';\r\nimport { parseResJson } from './parsers/parseResJson';\r\nimport { type IParseResxOptionsBase, parseResx } from './parsers/parseResx';\r\n\r\n/**\r\n * @public\r\n */\r\nexport type ParserKind = 'resx' | 'loc.json' | 'resjson';\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IParseLocFileOptions extends IParseFileOptions, IParseResxOptionsBase {\r\n parser?: ParserKind;\r\n}\r\n\r\ninterface IParseCacheEntry {\r\n content: string;\r\n parsedFile: ILocalizationFile;\r\n ignoreString: IgnoreStringFunction | undefined;\r\n}\r\n\r\nconst parseCache: Map<string, IParseCacheEntry> = new Map<string, IParseCacheEntry>();\r\n\r\nexport function selectParserByFilePath(filePath: string): ParserKind {\r\n if (/\\.resx$/i.test(filePath)) {\r\n return 'resx';\r\n } else if (/\\.(resx|loc)\\.json$/i.test(filePath)) {\r\n return 'loc.json';\r\n } else if (/\\.resjson$/i.test(filePath)) {\r\n return 'resjson';\r\n } else {\r\n throw new Error(`Unsupported file extension in file: ${filePath}`);\r\n }\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport function parseLocFile(options: IParseLocFileOptions): ILocalizationFile {\r\n const { parser = selectParserByFilePath(options.filePath) } = options;\r\n\r\n const fileCacheKey: string = `${options.filePath}?${parser}&${options.resxNewlineNormalization || 'none'}`;\r\n const parseCacheEntry: IParseCacheEntry | undefined = parseCache.get(fileCacheKey);\r\n if (parseCacheEntry) {\r\n if (\r\n parseCacheEntry.content === options.content &&\r\n parseCacheEntry.ignoreString === options.ignoreString\r\n ) {\r\n return parseCacheEntry.parsedFile;\r\n }\r\n }\r\n\r\n let parsedFile: ILocalizationFile;\r\n switch (parser) {\r\n case 'resx': {\r\n parsedFile = parseResx(options);\r\n break;\r\n }\r\n\r\n case 'loc.json': {\r\n parsedFile = parseLocJson(options);\r\n break;\r\n }\r\n\r\n case 'resjson': {\r\n parsedFile = parseResJson(options);\r\n break;\r\n }\r\n\r\n default: {\r\n throw new Error(`Unsupported parser: ${parser}`);\r\n }\r\n }\r\n\r\n parseCache.set(fileCacheKey, {\r\n content: options.content,\r\n parsedFile,\r\n ignoreString: options.ignoreString\r\n });\r\n\r\n return parsedFile;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pseudolocalization.js","sourceRoot":"","sources":["../src/Pseudolocalization.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,4CAAoB;AACpB,oEAA0D;AAI1D,MAAM,gBAAgB,GAAW,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAOrF;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,OAA6B;IAC9D,MAAM,gBAAgB,GAAW,8BAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACvE,MAAM,OAAO,GAET;QACF,YAAY,EAAE,SAAS;KACxB,CAAC;IAEF,kGAAkG;IAClG,YAAE,CAAC,eAAe,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACjC,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD;IAED,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,iGAAiG;IACjG,OAAO,YAAY,CAAC,GAAG,CAAC;AAC1B,CAAC;AAlBD,gDAkBC","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 vm from 'vm';\nimport { FileSystem } from '@rushstack/node-core-library';\n\nimport type { IPseudolocaleOptions } from './interfaces';\n\nconst pseudolocalePath: string = require.resolve('pseudolocale/pseudolocale.min.js');\n\ninterface IPseudolocale {\n option: IPseudolocaleOptions;\n str(str: string): string;\n}\n\n/**\n * Get a function that pseudolocalizes a string.\n *\n * @public\n */\nexport function getPseudolocalizer(options: IPseudolocaleOptions): (str: string) => string {\n const pseudolocaleCode: string = FileSystem.readFile(pseudolocalePath);\n const context: {\n pseudolocale: IPseudolocale | undefined;\n } = {\n pseudolocale: undefined\n };\n\n // Load pseudolocale in an isolated context because the configuration for is stored on a singleton\n vm.runInNewContext(pseudolocaleCode, context);\n const { pseudolocale } = context;\n if (!pseudolocale) {\n throw new Error(`Failed to load pseudolocale module`);\n }\n\n Object.assign(pseudolocale.option, options);\n // `pseudolocale.str` captures `pseudolocale` in its closure and refers to `pseudolocale.option`.\n return pseudolocale.str;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Pseudolocalization.js","sourceRoot":"","sources":["../src/Pseudolocalization.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,4CAAoB;AACpB,oEAA0D;AAI1D,MAAM,gBAAgB,GAAW,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAOrF;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,OAA6B;IAC9D,MAAM,gBAAgB,GAAW,8BAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACvE,MAAM,OAAO,GAET;QACF,YAAY,EAAE,SAAS;KACxB,CAAC;IAEF,kGAAkG;IAClG,YAAE,CAAC,eAAe,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACjC,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD;IAED,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,iGAAiG;IACjG,OAAO,YAAY,CAAC,GAAG,CAAC;AAC1B,CAAC;AAlBD,gDAkBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport vm from 'vm';\r\nimport { FileSystem } from '@rushstack/node-core-library';\r\n\r\nimport type { IPseudolocaleOptions } from './interfaces';\r\n\r\nconst pseudolocalePath: string = require.resolve('pseudolocale/pseudolocale.min.js');\r\n\r\ninterface IPseudolocale {\r\n option: IPseudolocaleOptions;\r\n str(str: string): string;\r\n}\r\n\r\n/**\r\n * Get a function that pseudolocalizes a string.\r\n *\r\n * @public\r\n */\r\nexport function getPseudolocalizer(options: IPseudolocaleOptions): (str: string) => string {\r\n const pseudolocaleCode: string = FileSystem.readFile(pseudolocalePath);\r\n const context: {\r\n pseudolocale: IPseudolocale | undefined;\r\n } = {\r\n pseudolocale: undefined\r\n };\r\n\r\n // Load pseudolocale in an isolated context because the configuration for is stored on a singleton\r\n vm.runInNewContext(pseudolocaleCode, context);\r\n const { pseudolocale } = context;\r\n if (!pseudolocale) {\r\n throw new Error(`Failed to load pseudolocale module`);\r\n }\r\n\r\n Object.assign(pseudolocale.option, options);\r\n // `pseudolocale.str` captures `pseudolocale` in its closure and refers to `pseudolocale.option`.\r\n return pseudolocale.str;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypingsGenerator.js","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAIsC;AAItC,mDAA+C;AAiB/C;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,gDAA4B;IAChE,YAAmB,OAAiC;QAClD,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;QACjD,KAAK,CAAC;YACJ,GAAG,OAAO;YACV,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,CAAC;YAChE,uBAAuB,EAAE,CAAC,YAAoB,EAAE,QAAgB,EAAE,YAAoB,EAAE,EAAE;gBACxF,MAAM,WAAW,GAAsB,IAAA,4BAAY,EAAC;oBAClD,QAAQ,EAAE,QAAQ;oBAClB,OAAO,EAAE,YAAY;oBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAS;oBACjC,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;oBAC1D,yBAAyB,EAAE,OAAO,CAAC,yBAAyB;oBAC5D,YAAY;iBACb,CAAC,CAAC;gBAEH,MAAM,OAAO,GAAyB,EAAE,CAAC;gBAEzC,wCAAwC;gBACxC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;oBACpC,IAAI,OAAO,GAAuB,WAAW,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;oBAClE,IAAI,cAAc,EAAE;wBAClB,OAAO,GAAG,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;qBAC7D;oBAED,OAAO,CAAC,IAAI,CAAC;wBACX,UAAU,EAAE,UAAU;wBACtB,OAAO;qBACR,CAAC,CAAC;iBACJ;gBAED,OAAO,EAAE,OAAO,EAAE,CAAC;YACrB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAnCD,4CAmCC","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 {\n StringValuesTypingsGenerator,\n type IStringValueTyping,\n type ITypingsGeneratorBaseOptions\n} from '@rushstack/typings-generator';\nimport type { NewlineKind } from '@rushstack/node-core-library';\n\nimport type { IgnoreStringFunction, ILocalizationFile } from './interfaces';\nimport { parseLocFile } from './LocFileParser';\n\n/**\n * @public\n */\nexport interface ITypingsGeneratorOptions extends ITypingsGeneratorBaseOptions {\n exportAsDefault?: boolean;\n resxNewlineNormalization?: NewlineKind | undefined;\n ignoreMissingResxComments?: boolean | undefined;\n ignoreString?: IgnoreStringFunction;\n processComment?: (\n comment: string | undefined,\n resxFilePath: string,\n stringName: string\n ) => string | undefined;\n}\n\n/**\n * This is a simple tool that generates .d.ts files for .loc.json, .resx.json, .resjson, and .resx files.\n *\n * @public\n */\nexport class TypingsGenerator extends StringValuesTypingsGenerator {\n public constructor(options: ITypingsGeneratorOptions) {\n const { ignoreString, processComment } = options;\n super({\n ...options,\n fileExtensions: ['.resx', '.resx.json', '.loc.json', '.resjson'],\n parseAndGenerateTypings: (fileContents: string, filePath: string, resxFilePath: string) => {\n const locFileData: ILocalizationFile = parseLocFile({\n filePath: filePath,\n content: fileContents,\n terminal: this._options.terminal!,\n resxNewlineNormalization: options.resxNewlineNormalization,\n ignoreMissingResxComments: options.ignoreMissingResxComments,\n ignoreString\n });\n\n const typings: IStringValueTyping[] = [];\n\n // eslint-disable-next-line guard-for-in\n for (const stringName in locFileData) {\n let comment: string | undefined = locFileData[stringName].comment;\n if (processComment) {\n comment = processComment(comment, resxFilePath, stringName);\n }\n\n typings.push({\n exportName: stringName,\n comment\n });\n }\n\n return { typings };\n }\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TypingsGenerator.js","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAIsC;AAItC,mDAA+C;AAiB/C;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,gDAA4B;IAChE,YAAmB,OAAiC;QAClD,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;QACjD,KAAK,CAAC;YACJ,GAAG,OAAO;YACV,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,CAAC;YAChE,uBAAuB,EAAE,CAAC,YAAoB,EAAE,QAAgB,EAAE,YAAoB,EAAE,EAAE;gBACxF,MAAM,WAAW,GAAsB,IAAA,4BAAY,EAAC;oBAClD,QAAQ,EAAE,QAAQ;oBAClB,OAAO,EAAE,YAAY;oBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAS;oBACjC,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;oBAC1D,yBAAyB,EAAE,OAAO,CAAC,yBAAyB;oBAC5D,YAAY;iBACb,CAAC,CAAC;gBAEH,MAAM,OAAO,GAAyB,EAAE,CAAC;gBAEzC,wCAAwC;gBACxC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;oBACpC,IAAI,OAAO,GAAuB,WAAW,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;oBAClE,IAAI,cAAc,EAAE;wBAClB,OAAO,GAAG,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;qBAC7D;oBAED,OAAO,CAAC,IAAI,CAAC;wBACX,UAAU,EAAE,UAAU;wBACtB,OAAO;qBACR,CAAC,CAAC;iBACJ;gBAED,OAAO,EAAE,OAAO,EAAE,CAAC;YACrB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAnCD,4CAmCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n StringValuesTypingsGenerator,\r\n type IStringValueTyping,\r\n type ITypingsGeneratorBaseOptions\r\n} from '@rushstack/typings-generator';\r\nimport type { NewlineKind } from '@rushstack/node-core-library';\r\n\r\nimport type { IgnoreStringFunction, ILocalizationFile } from './interfaces';\r\nimport { parseLocFile } from './LocFileParser';\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ITypingsGeneratorOptions extends ITypingsGeneratorBaseOptions {\r\n exportAsDefault?: boolean;\r\n resxNewlineNormalization?: NewlineKind | undefined;\r\n ignoreMissingResxComments?: boolean | undefined;\r\n ignoreString?: IgnoreStringFunction;\r\n processComment?: (\r\n comment: string | undefined,\r\n resxFilePath: string,\r\n stringName: string\r\n ) => string | undefined;\r\n}\r\n\r\n/**\r\n * This is a simple tool that generates .d.ts files for .loc.json, .resx.json, .resjson, and .resx files.\r\n *\r\n * @public\r\n */\r\nexport class TypingsGenerator extends StringValuesTypingsGenerator {\r\n public constructor(options: ITypingsGeneratorOptions) {\r\n const { ignoreString, processComment } = options;\r\n super({\r\n ...options,\r\n fileExtensions: ['.resx', '.resx.json', '.loc.json', '.resjson'],\r\n parseAndGenerateTypings: (fileContents: string, filePath: string, resxFilePath: string) => {\r\n const locFileData: ILocalizationFile = parseLocFile({\r\n filePath: filePath,\r\n content: fileContents,\r\n terminal: this._options.terminal!,\r\n resxNewlineNormalization: options.resxNewlineNormalization,\r\n ignoreMissingResxComments: options.ignoreMissingResxComments,\r\n ignoreString\r\n });\r\n\r\n const typings: IStringValueTyping[] = [];\r\n\r\n // eslint-disable-next-line guard-for-in\r\n for (const stringName in locFileData) {\r\n let comment: string | undefined = locFileData[stringName].comment;\r\n if (processComment) {\r\n comment = processComment(comment, resxFilePath, stringName);\r\n }\r\n\r\n typings.push({\r\n exportName: stringName,\r\n comment\r\n });\r\n }\r\n\r\n return { typings };\r\n }\r\n });\r\n }\r\n}\r\n"]}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAe3D,uDAAsD;AAA7C,4GAAA,YAAY,OAAA;AACrB,uDAAsD;AAA7C,4GAAA,YAAY,OAAA;AACrB,iDAA0F;AAAjF,sGAAA,SAAS,OAAA;AAClB,iDAAiF;AAAxE,6GAAA,YAAY,OAAA;AACrB,uDAAgF;AAA7C,oHAAA,gBAAgB,OAAA;AACnD,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * Some utilities for working with Rush Stack localization files.\n *\n * @packageDocumentation\n */\n\nexport type {\n ILocalizationFile,\n ILocalizedString,\n IPseudolocaleOptions,\n IParseFileOptions,\n IgnoreStringFunction\n} from './interfaces';\nexport { parseLocJson } from './parsers/parseLocJson';\nexport { parseResJson } from './parsers/parseResJson';\nexport { parseResx, IParseResxOptions, IParseResxOptionsBase } from './parsers/parseResx';\nexport { parseLocFile, IParseLocFileOptions, ParserKind } from './LocFileParser';\nexport { ITypingsGeneratorOptions, TypingsGenerator } from './TypingsGenerator';\nexport { getPseudolocalizer } from './Pseudolocalization';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAe3D,uDAAsD;AAA7C,4GAAA,YAAY,OAAA;AACrB,uDAAsD;AAA7C,4GAAA,YAAY,OAAA;AACrB,iDAA0F;AAAjF,sGAAA,SAAS,OAAA;AAClB,iDAAiF;AAAxE,6GAAA,YAAY,OAAA;AACrB,uDAAgF;AAA7C,oHAAA,gBAAgB,OAAA;AACnD,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * Some utilities for working with Rush Stack localization files.\r\n *\r\n * @packageDocumentation\r\n */\r\n\r\nexport type {\r\n ILocalizationFile,\r\n ILocalizedString,\r\n IPseudolocaleOptions,\r\n IParseFileOptions,\r\n IgnoreStringFunction\r\n} from './interfaces';\r\nexport { parseLocJson } from './parsers/parseLocJson';\r\nexport { parseResJson } from './parsers/parseResJson';\r\nexport { parseResx, IParseResxOptions, IParseResxOptionsBase } from './parsers/parseResx';\r\nexport { parseLocFile, IParseLocFileOptions, ParserKind } from './LocFileParser';\r\nexport { ITypingsGeneratorOptions, TypingsGenerator } from './TypingsGenerator';\r\nexport { getPseudolocalizer } from './Pseudolocalization';\r\n"]}
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.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\n/**\n * Options for the pseudolocale library.\n *\n * @internalRemarks\n * Eventually this should be replaced with DefinitelyTyped types.\n *\n * @public\n */\nexport interface IPseudolocaleOptions {\n prepend?: string;\n append?: string;\n delimiter?: string;\n startDelimiter?: string;\n endDelimiter?: string;\n extend?: number;\n override?: string;\n}\n\n/**\n * @public\n */\nexport interface ILocalizationFile {\n [stringName: string]: ILocalizedString;\n}\n\n/**\n * @public\n */\nexport interface ILocalizedString {\n value: string;\n comment?: string;\n}\n\n/**\n * @public\n */\nexport interface IParseFileOptions {\n content: string;\n filePath: string;\n /**\n * Optionally, provide a function that will be called for each string. If the function returns `true`\n * the string will not be included.\n */\n ignoreString?: IgnoreStringFunction;\n}\n\n/**\n * @public\n */\nexport type IgnoreStringFunction = (filePath: string, stringName: string) => boolean;\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * Options for the pseudolocale library.\r\n *\r\n * @internalRemarks\r\n * Eventually this should be replaced with DefinitelyTyped types.\r\n *\r\n * @public\r\n */\r\nexport interface IPseudolocaleOptions {\r\n prepend?: string;\r\n append?: string;\r\n delimiter?: string;\r\n startDelimiter?: string;\r\n endDelimiter?: string;\r\n extend?: number;\r\n override?: string;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocalizationFile {\r\n [stringName: string]: ILocalizedString;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ILocalizedString {\r\n value: string;\r\n comment?: string;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IParseFileOptions {\r\n content: string;\r\n filePath: string;\r\n /**\r\n * Optionally, provide a function that will be called for each string. If the function returns `true`\r\n * the string will not be included.\r\n */\r\n ignoreString?: IgnoreStringFunction;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport type IgnoreStringFunction = (filePath: string, stringName: string) => boolean;\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseLocJson.js","sourceRoot":"","sources":["../../src/parsers/parseLocJson.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,oEAAoE;AAGpE,yFAA2D;AAE3D,MAAM,eAAe,GAAe,8BAAU,CAAC,gBAAgB,CAAC,6BAAa,CAAC,CAAC;AAE/E;;GAEG;AACH,SAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAqB;IACjF,MAAM,UAAU,GAAsB,4BAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACpE,IAAI;QACF,eAAe,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;KACtD;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,EAAE,CAAC,CAAC;KACzD;IAED,IAAI,YAAY,EAAE;QAChB,MAAM,aAAa,GAAsB,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC1D,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE;gBAChC,aAAa,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;aACjC;SACF;QAED,OAAO,aAAa,CAAC;KACtB;SAAM;QACL,OAAO,UAAU,CAAC;KACnB;AACH,CAAC;AApBD,oCAoBC","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 { JsonFile, JsonSchema } from '@rushstack/node-core-library';\n\nimport type { ILocalizationFile, IParseFileOptions } from '../interfaces';\nimport locJsonSchema from '../schemas/locJson.schema.json';\n\nconst LOC_JSON_SCHEMA: JsonSchema = JsonSchema.fromLoadedObject(locJsonSchema);\n\n/**\n * @public\n */\nexport function parseLocJson({ content, filePath, ignoreString }: IParseFileOptions): ILocalizationFile {\n const parsedFile: ILocalizationFile = JsonFile.parseString(content);\n try {\n LOC_JSON_SCHEMA.validateObject(parsedFile, filePath);\n } catch (e) {\n throw new Error(`The loc file is invalid. Error: ${e}`);\n }\n\n if (ignoreString) {\n const newParsedFile: ILocalizationFile = {};\n for (const [key, stringData] of Object.entries(parsedFile)) {\n if (!ignoreString(filePath, key)) {\n newParsedFile[key] = stringData;\n }\n }\n\n return newParsedFile;\n } else {\n return parsedFile;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parseLocJson.js","sourceRoot":"","sources":["../../src/parsers/parseLocJson.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,oEAAoE;AAGpE,yFAA2D;AAE3D,MAAM,eAAe,GAAe,8BAAU,CAAC,gBAAgB,CAAC,6BAAa,CAAC,CAAC;AAE/E;;GAEG;AACH,SAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAqB;IACjF,MAAM,UAAU,GAAsB,4BAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACpE,IAAI;QACF,eAAe,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;KACtD;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,EAAE,CAAC,CAAC;KACzD;IAED,IAAI,YAAY,EAAE;QAChB,MAAM,aAAa,GAAsB,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC1D,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE;gBAChC,aAAa,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;aACjC;SACF;QAED,OAAO,aAAa,CAAC;KACtB;SAAM;QACL,OAAO,UAAU,CAAC;KACnB;AACH,CAAC;AApBD,oCAoBC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { JsonFile, JsonSchema } from '@rushstack/node-core-library';\r\n\r\nimport type { ILocalizationFile, IParseFileOptions } from '../interfaces';\r\nimport locJsonSchema from '../schemas/locJson.schema.json';\r\n\r\nconst LOC_JSON_SCHEMA: JsonSchema = JsonSchema.fromLoadedObject(locJsonSchema);\r\n\r\n/**\r\n * @public\r\n */\r\nexport function parseLocJson({ content, filePath, ignoreString }: IParseFileOptions): ILocalizationFile {\r\n const parsedFile: ILocalizationFile = JsonFile.parseString(content);\r\n try {\r\n LOC_JSON_SCHEMA.validateObject(parsedFile, filePath);\r\n } catch (e) {\r\n throw new Error(`The loc file is invalid. Error: ${e}`);\r\n }\r\n\r\n if (ignoreString) {\r\n const newParsedFile: ILocalizationFile = {};\r\n for (const [key, stringData] of Object.entries(parsedFile)) {\r\n if (!ignoreString(filePath, key)) {\r\n newParsedFile[key] = stringData;\r\n }\r\n }\r\n\r\n return newParsedFile;\r\n } else {\r\n return parsedFile;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseResJson.js","sourceRoot":"","sources":["../../src/parsers/parseResJson.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAwD;AAIxD;;GAEG;AACH,SAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAqB;IACjF,MAAM,WAAW,GAA2B,4BAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1E,MAAM,UAAU,GAAsB,EAAE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ft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { JsonFile } from '@rushstack/node-core-library';\n\nimport type { ILocalizationFile, IParseFileOptions } from '../interfaces';\n\n/**\n * @public\n */\nexport function parseResJson({ content, ignoreString, filePath }: IParseFileOptions): ILocalizationFile {\n const resjsonFile: Record<string, string> = JsonFile.parseString(content);\n const parsedFile: ILocalizationFile = {};\n\n const usedComments: Map<string, boolean> = new Map();\n for (const [key, value] of Object.entries(resjsonFile)) {\n if (key.startsWith('_') && key.endsWith('.comment')) {\n if (!usedComments.has(key)) {\n usedComments.set(key, false);\n }\n } else {\n const commentKey: string = `_${key}.comment`;\n const comment: string | undefined = resjsonFile[commentKey];\n usedComments.set(commentKey, true);\n\n if (!ignoreString?.(filePath, key)) {\n parsedFile[key] = { value, comment };\n }\n }\n }\n\n const orphanComments: string[] = [];\n for (const [key, used] of usedComments) {\n if (!used) {\n orphanComments.push(key.slice(1, -'.comment'.length));\n }\n }\n\n if (orphanComments.length > 0) {\n throw new Error(\n 'The resjson file is invalid. Comments exist for the following string keys ' +\n `that don't have values: ${orphanComments.join(', ')}.`\n );\n }\n\n return parsedFile;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parseResJson.js","sourceRoot":"","sources":["../../src/parsers/parseResJson.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAwD;AAIxD;;GAEG;AACH,SAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAqB;IACjF,MAAM,WAAW,GAA2B,4BAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1E,MAAM,UAAU,GAAsB,EAAE,CAAC;IAEzC,MAAM,YAAY,GAAyB,IAAI,GAAG,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACtD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YACnD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAC1B,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aAC9B;SACF;aAAM;YACL,MAAM,UAAU,GAAW,IAAI,GAAG,UAAU,CAAC;YAC7C,MAAM,OAAO,GAAuB,WAAW,CAAC,UAAU,CAAC,CAAC;YAC5D,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAEnC,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,QAAQ,EAAE,GAAG,CAAC,CAAA,EAAE;gBAClC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;aACtC;SACF;KACF;IAED,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,YAAY,EAAE;QACtC,IAAI,CAAC,IAAI,EAAE;YACT,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;SACvD;KACF;IAED,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,MAAM,IAAI,KAAK,CACb,4EAA4E;YAC1E,2BAA2B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC1D,CAAC;KACH;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AApCD,oCAoCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { JsonFile } from '@rushstack/node-core-library';\r\n\r\nimport type { ILocalizationFile, IParseFileOptions } from '../interfaces';\r\n\r\n/**\r\n * @public\r\n */\r\nexport function parseResJson({ content, ignoreString, filePath }: IParseFileOptions): ILocalizationFile {\r\n const resjsonFile: Record<string, string> = JsonFile.parseString(content);\r\n const parsedFile: ILocalizationFile = {};\r\n\r\n const usedComments: Map<string, boolean> = new Map();\r\n for (const [key, value] of Object.entries(resjsonFile)) {\r\n if (key.startsWith('_') && key.endsWith('.comment')) {\r\n if (!usedComments.has(key)) {\r\n usedComments.set(key, false);\r\n }\r\n } else {\r\n const commentKey: string = `_${key}.comment`;\r\n const comment: string | undefined = resjsonFile[commentKey];\r\n usedComments.set(commentKey, true);\r\n\r\n if (!ignoreString?.(filePath, key)) {\r\n parsedFile[key] = { value, comment };\r\n }\r\n }\r\n }\r\n\r\n const orphanComments: string[] = [];\r\n for (const [key, used] of usedComments) {\r\n if (!used) {\r\n orphanComments.push(key.slice(1, -'.comment'.length));\r\n }\r\n }\r\n\r\n if (orphanComments.length > 0) {\r\n throw new Error(\r\n 'The resjson file is invalid. Comments exist for the following string keys ' +\r\n `that don't have values: ${orphanComments.join(', ')}.`\r\n );\r\n }\r\n\r\n return parsedFile;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseResx.js","sourceRoot":"","sources":["../../src/parsers/parseResx.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAsF;AACtF,mCAAsD;AA6BtD;;GAEG;AACH,SAAgB,SAAS,CAAC,OAA0B;IAClD,MAAM,UAAU,GAA8B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrG,MAAM,YAAY,GAA8B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzG,MAAM,gBAAgB,GAAsB;QAC1C,QAAQ,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;QAClD,UAAU,EAAE,CAAC,OAAe,EAAE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CAAC,IAAI,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;KACxG;SAAM;QACL,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KAClE;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,OAAmC,EACnC,OAAe,EACf,OAAkC;IAElC,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,gBAAgB,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;KAC1G;SAAM;QACL,OAAO,CAAC,gBAAgB,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KACpE;AACH,CAAC;AAED,SAAS,gBAAgB,CACvB,SAAoC,EACpC,OAAe,EACf,QAAgB,EAChB,IAAa,EACb,QAAiB;IAEjB,IAAI,QAAgB,CAAC;IACrB,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,QAAQ,GAAG,GAAG,QAAQ,IAAI,IAAI,IAAI,QAAQ,GAAG,CAAC;KAC/C;SAAM,IAAI,IAAI,KAAK,SAAS,EAAE;QAC7B,QAAQ,GAAG,GAAG,QAAQ,IAAI,IAAI,GAAG,CAAC;KACnC;SAAM;QACL,QAAQ,GAAG,QAAQ,CAAC;KACrB;IAED,SAAS,CAAC,GAAG,QAAQ,KAAK,OAAO,EAAE,CAAC,CAAC;AACvC,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 { type ITerminal, Text, type NewlineKind } from '@rushstack/node-core-library';\nimport { XmlDocument, type XmlElement } from 'xmldoc';\n\nimport type { ILocalizedString, ILocalizationFile, IParseFileOptions } from '../interfaces';\n\n/**\n * @public\n */\nexport interface IParseResxOptions extends IParseFileOptions, IParseResxOptionsBase {}\n\n/**\n * @public\n */\nexport interface IParseResxOptionsBase {\n terminal: ITerminal;\n resxNewlineNormalization: NewlineKind | undefined;\n ignoreMissingResxComments: boolean | undefined;\n}\n\ninterface ILoggingFunctions {\n logError: (message: string) => void;\n logWarning: (message: string) => void;\n logFileError: (message: string, filePath: string, line?: number, position?: number) => void;\n logFileWarning: (message: string, filePath: string, line?: number, position?: number) => void;\n}\n\ninterface IResxReaderOptionsInternal extends Omit<IParseResxOptions, 'terminal'> {\n loggingFunctions: ILoggingFunctions;\n}\n\n/**\n * @public\n */\nexport function parseResx(options: IParseResxOptions): ILocalizationFile {\n const writeError: (message: string) => void = options.terminal.writeErrorLine.bind(options.terminal);\n const writeWarning: (message: string) => void = options.terminal.writeWarningLine.bind(options.terminal);\n const loggingFunctions: ILoggingFunctions = {\n logError: (message: string) => writeError(message),\n logWarning: (message: string) => writeWarning(message),\n logFileError: (message: string, filePath: string, line?: number, position?: number) => {\n _logWithLocation(writeError, message, filePath, line, position);\n },\n logFileWarning: (message: string, filePath: string, line?: number, position?: number) => {\n _logWithLocation(writeWarning, message, filePath, line, position);\n }\n };\n\n return _readResxAsLocFileInternal({\n ...options,\n loggingFunctions\n });\n}\n\nfunction _readResxAsLocFileInternal(options: IResxReaderOptionsInternal): ILocalizationFile {\n const { ignoreString } = options;\n const xmlDocument: XmlDocument = new XmlDocument(options.content);\n\n if (xmlDocument.name !== 'root') {\n _logErrorWithLocation(\n options,\n `Expected RESX to have a \"root\" element, found \"${xmlDocument.name}\"`,\n xmlDocument\n );\n }\n\n const locFile: ILocalizationFile = {};\n\n for (const childNode of xmlDocument.children) {\n switch (childNode.type) {\n case 'element': {\n switch (childNode.name) {\n case 'data': {\n const stringName: string = childNode.attr.name;\n if (!stringName) {\n _logErrorWithLocation(options, 'Unexpected missing or empty string name', childNode);\n } else {\n if (locFile.hasOwnProperty(stringName)) {\n _logErrorWithLocation(options, `Duplicate string value \"${stringName}\"`, childNode);\n }\n\n const locString: ILocalizedString | undefined = _readDataElement(options, childNode);\n\n if (locString && !ignoreString?.(options.filePath, stringName)) {\n locFile[stringName] = locString;\n }\n }\n\n break;\n }\n\n // Other allowed elements\n case 'xsd:schema':\n case 'resheader':\n break;\n\n default:\n _logErrorWithLocation(options, `Unexpected RESX element ${childNode.name}`, childNode);\n }\n\n break;\n }\n\n case 'text': {\n if (childNode.text.trim() !== '') {\n _logErrorWithLocation(options, 'Found unexpected non-empty text node in RESX');\n }\n\n break;\n }\n\n case 'comment':\n break;\n\n default:\n _logErrorWithLocation(options, `Unexpected ${childNode.type} child in RESX`);\n break;\n }\n }\n\n return locFile;\n}\n\nfunction _readDataElement(\n options: IResxReaderOptionsInternal,\n dataElement: XmlElement\n): ILocalizedString | undefined {\n let foundCommentElement: boolean = false;\n let foundValueElement: boolean = false;\n let comment: string | undefined = undefined;\n let value: string | undefined = undefined;\n\n for (const childNode of dataElement.children) {\n switch (childNode.type) {\n case 'element': {\n switch (childNode.name) {\n case 'value': {\n if (foundValueElement) {\n _logErrorWithLocation(options, 'Duplicate <value> element found', childNode);\n } else {\n foundValueElement = true;\n value = _readTextElement(options, childNode);\n if (value && options.resxNewlineNormalization) {\n value = Text.convertTo(value, options.resxNewlineNormalization);\n }\n }\n\n break;\n }\n\n case 'comment': {\n if (foundCommentElement) {\n _logErrorWithLocation(options, 'Duplicate <comment> element found', childNode);\n } else {\n foundCommentElement = true;\n comment = _readTextElement(options, childNode);\n }\n\n break;\n }\n\n default:\n _logErrorWithLocation(options, `Unexpected RESX element ${childNode.name}`, childNode);\n break;\n }\n\n break;\n }\n\n case 'text': {\n if (childNode.text.trim() !== '') {\n _logErrorWithLocation(\n options,\n 'Found unexpected non-empty text node in RESX <data> element',\n dataElement\n );\n }\n\n break;\n }\n\n case 'comment':\n break;\n\n default:\n _logErrorWithLocation(\n options,\n `Unexpected ${childNode.type} child in RESX <data> element`,\n dataElement\n );\n }\n }\n\n if (!foundValueElement) {\n _logErrorWithLocation(options, 'Missing string value in <data> element', dataElement);\n } else {\n if (comment === undefined && options.ignoreMissingResxComments === false) {\n _logWarningWithLocation(options, 'Missing string comment in <data> element', dataElement);\n }\n\n return {\n value: value || '',\n comment\n };\n }\n}\n\nfunction _readTextElement(options: IResxReaderOptionsInternal, element: XmlElement): string | undefined {\n let foundText: string | undefined = undefined;\n\n for (const childNode of element.children) {\n switch (childNode.type) {\n case 'cdata':\n case 'text': {\n if (foundText !== undefined) {\n _logErrorWithLocation(options, 'More than one child node found containing text content', element);\n break;\n }\n\n foundText = childNode.type === 'text' ? childNode.text : childNode.cdata;\n break;\n }\n\n case 'comment':\n break;\n\n case 'element':\n _logErrorWithLocation(options, `Unexpected element`, childNode);\n break;\n\n default:\n _logErrorWithLocation(options, `Unexpected ${element.type} child`, element);\n break;\n }\n }\n\n return foundText;\n}\n\nfunction _logErrorWithLocation(\n options: IResxReaderOptionsInternal,\n message: string,\n element?: XmlElement | XmlDocument\n): void {\n if (element) {\n options.loggingFunctions.logFileError(message, options.filePath, element.line + 1, element.column + 1);\n } else {\n options.loggingFunctions.logFileError(message, options.filePath);\n }\n}\n\nfunction _logWarningWithLocation(\n options: IResxReaderOptionsInternal,\n message: string,\n element?: XmlElement | XmlDocument\n): void {\n if (element) {\n options.loggingFunctions.logFileWarning(message, options.filePath, element.line + 1, element.column + 1);\n } else {\n options.loggingFunctions.logFileWarning(message, options.filePath);\n }\n}\n\nfunction _logWithLocation(\n loggingFn: (message: string) => void,\n message: string,\n filePath: string,\n line?: number,\n position?: number\n): void {\n let location: string;\n if (position !== undefined) {\n location = `${filePath}(${line},${position})`;\n } else if (line !== undefined) {\n location = `${filePath}(${line})`;\n } else {\n location = filePath;\n }\n\n loggingFn(`${location}: ${message}`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parseResx.js","sourceRoot":"","sources":["../../src/parsers/parseResx.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAsF;AACtF,mCAAsD;AA6BtD;;GA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AI,GAAG,CAAC;KACnC;SAAM;QACL,QAAQ,GAAG,QAAQ,CAAC;KACrB;IAED,SAAS,CAAC,GAAG,QAAQ,KAAK,OAAO,EAAE,CAAC,CAAC;AACvC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { type ITerminal, Text, type NewlineKind } from '@rushstack/node-core-library';\r\nimport { XmlDocument, type XmlElement } from 'xmldoc';\r\n\r\nimport type { ILocalizedString, ILocalizationFile, IParseFileOptions } from '../interfaces';\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IParseResxOptions extends IParseFileOptions, IParseResxOptionsBase {}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IParseResxOptionsBase {\r\n terminal: ITerminal;\r\n resxNewlineNormalization: NewlineKind | undefined;\r\n ignoreMissingResxComments: boolean | undefined;\r\n}\r\n\r\ninterface ILoggingFunctions {\r\n logError: (message: string) => void;\r\n logWarning: (message: string) => void;\r\n logFileError: (message: string, filePath: string, line?: number, position?: number) => void;\r\n logFileWarning: (message: string, filePath: string, line?: number, position?: number) => void;\r\n}\r\n\r\ninterface IResxReaderOptionsInternal extends Omit<IParseResxOptions, 'terminal'> {\r\n loggingFunctions: ILoggingFunctions;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport function parseResx(options: IParseResxOptions): ILocalizationFile {\r\n const writeError: (message: string) => void = options.terminal.writeErrorLine.bind(options.terminal);\r\n const writeWarning: (message: string) => void = options.terminal.writeWarningLine.bind(options.terminal);\r\n const loggingFunctions: ILoggingFunctions = {\r\n logError: (message: string) => writeError(message),\r\n logWarning: (message: string) => writeWarning(message),\r\n logFileError: (message: string, filePath: string, line?: number, position?: number) => {\r\n _logWithLocation(writeError, message, filePath, line, position);\r\n },\r\n logFileWarning: (message: string, filePath: string, line?: number, position?: number) => {\r\n _logWithLocation(writeWarning, message, filePath, line, position);\r\n }\r\n };\r\n\r\n return _readResxAsLocFileInternal({\r\n ...options,\r\n loggingFunctions\r\n });\r\n}\r\n\r\nfunction _readResxAsLocFileInternal(options: IResxReaderOptionsInternal): ILocalizationFile {\r\n const { ignoreString } = options;\r\n const xmlDocument: XmlDocument = new XmlDocument(options.content);\r\n\r\n if (xmlDocument.name !== 'root') {\r\n _logErrorWithLocation(\r\n options,\r\n `Expected RESX to have a \"root\" element, found \"${xmlDocument.name}\"`,\r\n xmlDocument\r\n );\r\n }\r\n\r\n const locFile: ILocalizationFile = {};\r\n\r\n for (const childNode of xmlDocument.children) {\r\n switch (childNode.type) {\r\n case 'element': {\r\n switch (childNode.name) {\r\n case 'data': {\r\n const stringName: string = childNode.attr.name;\r\n if (!stringName) {\r\n _logErrorWithLocation(options, 'Unexpected missing or empty string name', childNode);\r\n } else {\r\n if (locFile.hasOwnProperty(stringName)) {\r\n _logErrorWithLocation(options, `Duplicate string value \"${stringName}\"`, childNode);\r\n }\r\n\r\n const locString: ILocalizedString | undefined = _readDataElement(options, childNode);\r\n\r\n if (locString && !ignoreString?.(options.filePath, stringName)) {\r\n locFile[stringName] = locString;\r\n }\r\n }\r\n\r\n break;\r\n }\r\n\r\n // Other allowed elements\r\n case 'xsd:schema':\r\n case 'resheader':\r\n break;\r\n\r\n default:\r\n _logErrorWithLocation(options, `Unexpected RESX element ${childNode.name}`, childNode);\r\n }\r\n\r\n break;\r\n }\r\n\r\n case 'text': {\r\n if (childNode.text.trim() !== '') {\r\n _logErrorWithLocation(options, 'Found unexpected non-empty text node in RESX');\r\n }\r\n\r\n break;\r\n }\r\n\r\n case 'comment':\r\n break;\r\n\r\n default:\r\n _logErrorWithLocation(options, `Unexpected ${childNode.type} child in RESX`);\r\n break;\r\n }\r\n }\r\n\r\n return locFile;\r\n}\r\n\r\nfunction _readDataElement(\r\n options: IResxReaderOptionsInternal,\r\n dataElement: XmlElement\r\n): ILocalizedString | undefined {\r\n let foundCommentElement: boolean = false;\r\n let foundValueElement: boolean = false;\r\n let comment: string | undefined = undefined;\r\n let value: string | undefined = undefined;\r\n\r\n for (const childNode of dataElement.children) {\r\n switch (childNode.type) {\r\n case 'element': {\r\n switch (childNode.name) {\r\n case 'value': {\r\n if (foundValueElement) {\r\n _logErrorWithLocation(options, 'Duplicate <value> element found', childNode);\r\n } else {\r\n foundValueElement = true;\r\n value = _readTextElement(options, childNode);\r\n if (value && options.resxNewlineNormalization) {\r\n value = Text.convertTo(value, options.resxNewlineNormalization);\r\n }\r\n }\r\n\r\n break;\r\n }\r\n\r\n case 'comment': {\r\n if (foundCommentElement) {\r\n _logErrorWithLocation(options, 'Duplicate <comment> element found', childNode);\r\n } else {\r\n foundCommentElement = true;\r\n comment = _readTextElement(options, childNode);\r\n }\r\n\r\n break;\r\n }\r\n\r\n default:\r\n _logErrorWithLocation(options, `Unexpected RESX element ${childNode.name}`, childNode);\r\n break;\r\n }\r\n\r\n break;\r\n }\r\n\r\n case 'text': {\r\n if (childNode.text.trim() !== '') {\r\n _logErrorWithLocation(\r\n options,\r\n 'Found unexpected non-empty text node in RESX <data> element',\r\n dataElement\r\n );\r\n }\r\n\r\n break;\r\n }\r\n\r\n case 'comment':\r\n break;\r\n\r\n default:\r\n _logErrorWithLocation(\r\n options,\r\n `Unexpected ${childNode.type} child in RESX <data> element`,\r\n dataElement\r\n );\r\n }\r\n }\r\n\r\n if (!foundValueElement) {\r\n _logErrorWithLocation(options, 'Missing string value in <data> element', dataElement);\r\n } else {\r\n if (comment === undefined && options.ignoreMissingResxComments === false) {\r\n _logWarningWithLocation(options, 'Missing string comment in <data> element', dataElement);\r\n }\r\n\r\n return {\r\n value: value || '',\r\n comment\r\n };\r\n }\r\n}\r\n\r\nfunction _readTextElement(options: IResxReaderOptionsInternal, element: XmlElement): string | undefined {\r\n let foundText: string | undefined = undefined;\r\n\r\n for (const childNode of element.children) {\r\n switch (childNode.type) {\r\n case 'cdata':\r\n case 'text': {\r\n if (foundText !== undefined) {\r\n _logErrorWithLocation(options, 'More than one child node found containing text content', element);\r\n break;\r\n }\r\n\r\n foundText = childNode.type === 'text' ? childNode.text : childNode.cdata;\r\n break;\r\n }\r\n\r\n case 'comment':\r\n break;\r\n\r\n case 'element':\r\n _logErrorWithLocation(options, `Unexpected element`, childNode);\r\n break;\r\n\r\n default:\r\n _logErrorWithLocation(options, `Unexpected ${element.type} child`, element);\r\n break;\r\n }\r\n }\r\n\r\n return foundText;\r\n}\r\n\r\nfunction _logErrorWithLocation(\r\n options: IResxReaderOptionsInternal,\r\n message: string,\r\n element?: XmlElement | XmlDocument\r\n): void {\r\n if (element) {\r\n options.loggingFunctions.logFileError(message, options.filePath, element.line + 1, element.column + 1);\r\n } else {\r\n options.loggingFunctions.logFileError(message, options.filePath);\r\n }\r\n}\r\n\r\nfunction _logWarningWithLocation(\r\n options: IResxReaderOptionsInternal,\r\n message: string,\r\n element?: XmlElement | XmlDocument\r\n): void {\r\n if (element) {\r\n options.loggingFunctions.logFileWarning(message, options.filePath, element.line + 1, element.column + 1);\r\n } else {\r\n options.loggingFunctions.logFileWarning(message, options.filePath);\r\n }\r\n}\r\n\r\nfunction _logWithLocation(\r\n loggingFn: (message: string) => void,\r\n message: string,\r\n filePath: string,\r\n line?: number,\r\n position?: number\r\n): void {\r\n let location: string;\r\n if (position !== undefined) {\r\n location = `${filePath}(${line},${position})`;\r\n } else if (line !== undefined) {\r\n location = `${filePath}(${line})`;\r\n } else {\r\n location = filePath;\r\n }\r\n\r\n loggingFn(`${location}: ${message}`);\r\n}\r\n"]}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
-
"title": "Localizable JSON file",
|
|
4
|
-
|
|
5
|
-
"properties": {
|
|
6
|
-
"$schema": {
|
|
7
|
-
"description": "Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.",
|
|
8
|
-
"type": "string"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"patternProperties": {
|
|
12
|
-
"^[A-Za-z_][0-9A-Za-z_]*$": {
|
|
13
|
-
"type": "object",
|
|
14
|
-
"properties": {
|
|
15
|
-
"value": {
|
|
16
|
-
"type": "string"
|
|
17
|
-
},
|
|
18
|
-
"comment": {
|
|
19
|
-
"type": "string"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"additionalProperties": false,
|
|
23
|
-
"required": ["value"]
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"additionalProperties": false,
|
|
27
|
-
"type": "object"
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"title": "Localizable JSON file",
|
|
4
|
+
|
|
5
|
+
"properties": {
|
|
6
|
+
"$schema": {
|
|
7
|
+
"description": "Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.",
|
|
8
|
+
"type": "string"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"patternProperties": {
|
|
12
|
+
"^[A-Za-z_][0-9A-Za-z_]*$": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"value": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"comment": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"required": ["value"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"additionalProperties": false,
|
|
27
|
+
"type": "object"
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/localization-utilities",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.10",
|
|
4
4
|
"description": "This plugin contains some useful functions for localization.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "dist/localization-utilities.d.ts",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"pseudolocale": "~1.1.0",
|
|
15
15
|
"xmldoc": "~1.1.2",
|
|
16
16
|
"@rushstack/node-core-library": "3.61.0",
|
|
17
|
-
"@rushstack/typings-generator": "0.12.
|
|
17
|
+
"@rushstack/typings-generator": "0.12.10"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/xmldoc": "1.1.4",
|
|
21
|
-
"@rushstack/heft": "0.
|
|
21
|
+
"@rushstack/heft": "0.63.0",
|
|
22
22
|
"local-node-rig": "1.0.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|