@rushstack/localization-utilities 0.9.62 → 0.11.0
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/CHANGELOG.json +52 -0
- package/CHANGELOG.md +15 -1
- package/dist/localization-utilities.d.ts +14 -2
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/TypingsGenerator.d.ts +13 -3
- package/lib/TypingsGenerator.d.ts.map +1 -1
- package/lib/TypingsGenerator.js +31 -9
- package/lib/TypingsGenerator.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/parsers/parseLocJson.js +1 -1
- package/lib/parsers/parseLocJson.js.map +1 -1
- package/lib/schemas/locJson.schema.json +1 -7
- package/package.json +5 -5
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/localization-utilities",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.11.0",
|
|
6
|
+
"tag": "@rushstack/localization-utilities_v0.11.0",
|
|
7
|
+
"date": "Wed, 21 Aug 2024 05:43:04 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Expand the typings generator to take a richer set of options for default exports. See `exportAsDefault` in @rushstack/typings-generator's `StringValuesTypingsGenerator`. Also included is another property in `exportAsDefault`: `inferInterfaceNameFromFilename`."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@rushstack/node-core-library\" to `5.7.0`"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@rushstack/terminal\" to `0.14.0`"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"comment": "Updating dependency \"@rushstack/typings-generator\" to `0.13.0`"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `0.67.0`"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"version": "0.10.0",
|
|
32
|
+
"tag": "@rushstack/localization-utilities_v0.10.0",
|
|
33
|
+
"date": "Mon, 12 Aug 2024 22:16:04 GMT",
|
|
34
|
+
"comments": {
|
|
35
|
+
"minor": [
|
|
36
|
+
{
|
|
37
|
+
"comment": "Update the schema for `.loc.json` files to allow string names that include the `$` character."
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"dependency": [
|
|
41
|
+
{
|
|
42
|
+
"comment": "Updating dependency \"@rushstack/node-core-library\" to `5.6.0`"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"comment": "Updating dependency \"@rushstack/terminal\" to `0.13.4`"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"comment": "Updating dependency \"@rushstack/typings-generator\" to `0.12.63`"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `0.66.26`"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
4
56
|
{
|
|
5
57
|
"version": "0.9.62",
|
|
6
58
|
"tag": "@rushstack/localization-utilities_v0.9.62",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @rushstack/localization-utilities
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 21 Aug 2024 05:43:04 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.11.0
|
|
6
|
+
Wed, 21 Aug 2024 05:43:04 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Expand the typings generator to take a richer set of options for default exports. See `exportAsDefault` in @rushstack/typings-generator's `StringValuesTypingsGenerator`. Also included is another property in `exportAsDefault`: `inferInterfaceNameFromFilename`.
|
|
11
|
+
|
|
12
|
+
## 0.10.0
|
|
13
|
+
Mon, 12 Aug 2024 22:16:04 GMT
|
|
14
|
+
|
|
15
|
+
### Minor changes
|
|
16
|
+
|
|
17
|
+
- Update the schema for `.loc.json` files to allow string names that include the `$` character.
|
|
4
18
|
|
|
5
19
|
## 0.9.62
|
|
6
20
|
Fri, 02 Aug 2024 17:26:42 GMT
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { IExportAsDefaultOptions } from '@rushstack/typings-generator';
|
|
7
8
|
import type { ITerminal } from '@rushstack/terminal';
|
|
8
9
|
import { ITypingsGeneratorBaseOptions } from '@rushstack/typings-generator';
|
|
9
10
|
import { NewlineKind } from '@rushstack/node-core-library';
|
|
@@ -21,6 +22,17 @@ export declare function getPseudolocalizer(options: IPseudolocaleOptions): (str:
|
|
|
21
22
|
*/
|
|
22
23
|
export declare type IgnoreStringFunction = (filePath: string, stringName: string) => boolean;
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare interface IInferInterfaceNameExportAsDefaultOptions extends Omit<IExportAsDefaultOptions, 'interfaceName'> {
|
|
29
|
+
/**
|
|
30
|
+
* When `exportAsDefault` is true and this option is true, the default export interface name will be inferred
|
|
31
|
+
* from the filename.
|
|
32
|
+
*/
|
|
33
|
+
inferInterfaceNameFromFilename?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
/**
|
|
25
37
|
* @public
|
|
26
38
|
*/
|
|
@@ -93,11 +105,11 @@ export declare interface IPseudolocaleOptions {
|
|
|
93
105
|
* @public
|
|
94
106
|
*/
|
|
95
107
|
export declare interface ITypingsGeneratorOptions extends ITypingsGeneratorBaseOptions {
|
|
96
|
-
exportAsDefault?: boolean;
|
|
108
|
+
exportAsDefault?: boolean | IExportAsDefaultOptions | IInferInterfaceNameExportAsDefaultOptions;
|
|
97
109
|
resxNewlineNormalization?: NewlineKind | undefined;
|
|
98
110
|
ignoreMissingResxComments?: boolean | undefined;
|
|
99
111
|
ignoreString?: IgnoreStringFunction;
|
|
100
|
-
processComment?: (comment: string | undefined,
|
|
112
|
+
processComment?: (comment: string | undefined, relativeFilePath: string, stringName: string) => string | undefined;
|
|
101
113
|
}
|
|
102
114
|
|
|
103
115
|
/**
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import { StringValuesTypingsGenerator, type ITypingsGeneratorBaseOptions } from '@rushstack/typings-generator';
|
|
1
|
+
import { StringValuesTypingsGenerator, type IExportAsDefaultOptions, type ITypingsGeneratorBaseOptions } from '@rushstack/typings-generator';
|
|
2
2
|
import type { NewlineKind } from '@rushstack/node-core-library';
|
|
3
3
|
import type { IgnoreStringFunction } from './interfaces';
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IInferInterfaceNameExportAsDefaultOptions extends Omit<IExportAsDefaultOptions, 'interfaceName'> {
|
|
8
|
+
/**
|
|
9
|
+
* When `exportAsDefault` is true and this option is true, the default export interface name will be inferred
|
|
10
|
+
* from the filename.
|
|
11
|
+
*/
|
|
12
|
+
inferInterfaceNameFromFilename?: boolean;
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* @public
|
|
6
16
|
*/
|
|
7
17
|
export interface ITypingsGeneratorOptions extends ITypingsGeneratorBaseOptions {
|
|
8
|
-
exportAsDefault?: boolean;
|
|
18
|
+
exportAsDefault?: boolean | IExportAsDefaultOptions | IInferInterfaceNameExportAsDefaultOptions;
|
|
9
19
|
resxNewlineNormalization?: NewlineKind | undefined;
|
|
10
20
|
ignoreMissingResxComments?: boolean | undefined;
|
|
11
21
|
ignoreString?: IgnoreStringFunction;
|
|
12
|
-
processComment?: (comment: string | undefined,
|
|
22
|
+
processComment?: (comment: string | undefined, relativeFilePath: string, stringName: string) => string | undefined;
|
|
13
23
|
}
|
|
14
24
|
/**
|
|
15
25
|
* This is a simple tool that generates .d.ts files for .loc.json, .resx.json, .resjson, and .resx files.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypingsGenerator.d.ts","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,4BAA4B,EAE5B,KAAK,4BAA4B,EAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,oBAAoB,EAAqB,MAAM,cAAc,CAAC;AAG5E;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,4BAA4B;IAC5E,eAAe,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TypingsGenerator.d.ts","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,4BAA4B,EAC5B,KAAK,uBAAuB,EAE5B,KAAK,4BAA4B,EAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,oBAAoB,EAAqB,MAAM,cAAc,CAAC;AAG5E;;GAEG;AACH,MAAM,WAAW,yCACf,SAAQ,IAAI,CAAC,uBAAuB,EAAE,eAAe,CAAC;IACtD;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,4BAA4B;IAC5E,eAAe,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,yCAAyC,CAAC;IAEhG,wBAAwB,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAEnD,yBAAyB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEhD,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAEpC,cAAc,CAAC,EAAE,CACf,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,KACf,MAAM,GAAG,SAAS,CAAC;CACzB;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,4BAA4B;gBAC7C,OAAO,EAAE,wBAAwB;CAoErD"}
|
package/lib/TypingsGenerator.js
CHANGED
|
@@ -12,17 +12,20 @@ const LocFileParser_1 = require("./LocFileParser");
|
|
|
12
12
|
*/
|
|
13
13
|
class TypingsGenerator extends typings_generator_1.StringValuesTypingsGenerator {
|
|
14
14
|
constructor(options) {
|
|
15
|
-
const { ignoreString, processComment } = options;
|
|
15
|
+
const { ignoreString, processComment, resxNewlineNormalization, ignoreMissingResxComments, exportAsDefault } = options;
|
|
16
|
+
const inferDefaultExportInterfaceNameFromFilename = typeof exportAsDefault === 'object'
|
|
17
|
+
? exportAsDefault.inferInterfaceNameFromFilename
|
|
18
|
+
: undefined;
|
|
16
19
|
super({
|
|
17
20
|
...options,
|
|
18
21
|
fileExtensions: ['.resx', '.resx.json', '.loc.json', '.resjson'],
|
|
19
|
-
parseAndGenerateTypings: (
|
|
22
|
+
parseAndGenerateTypings: (content, filePath, relativeFilePath) => {
|
|
20
23
|
const locFileData = (0, LocFileParser_1.parseLocFile)({
|
|
21
|
-
filePath
|
|
22
|
-
content
|
|
23
|
-
terminal: this.
|
|
24
|
-
resxNewlineNormalization
|
|
25
|
-
ignoreMissingResxComments
|
|
24
|
+
filePath,
|
|
25
|
+
content,
|
|
26
|
+
terminal: this.terminal,
|
|
27
|
+
resxNewlineNormalization,
|
|
28
|
+
ignoreMissingResxComments,
|
|
26
29
|
ignoreString
|
|
27
30
|
});
|
|
28
31
|
const typings = [];
|
|
@@ -30,14 +33,33 @@ class TypingsGenerator extends typings_generator_1.StringValuesTypingsGenerator
|
|
|
30
33
|
for (const stringName in locFileData) {
|
|
31
34
|
let comment = locFileData[stringName].comment;
|
|
32
35
|
if (processComment) {
|
|
33
|
-
comment = processComment(comment,
|
|
36
|
+
comment = processComment(comment, relativeFilePath, stringName);
|
|
34
37
|
}
|
|
35
38
|
typings.push({
|
|
36
39
|
exportName: stringName,
|
|
37
40
|
comment
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
|
-
|
|
43
|
+
let exportAsDefaultInterfaceName;
|
|
44
|
+
if (inferDefaultExportInterfaceNameFromFilename) {
|
|
45
|
+
const lastSlashIndex = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
|
|
46
|
+
let extensionIndex = filePath.lastIndexOf('.');
|
|
47
|
+
if (filePath.slice(extensionIndex).toLowerCase() === '.json') {
|
|
48
|
+
extensionIndex = filePath.lastIndexOf('.', extensionIndex - 1);
|
|
49
|
+
}
|
|
50
|
+
const fileNameWithoutExtension = filePath.substring(lastSlashIndex + 1, extensionIndex);
|
|
51
|
+
const normalizedFileName = fileNameWithoutExtension.replace(/[^a-zA-Z0-9$_]/g, '');
|
|
52
|
+
const firstCharUpperCased = normalizedFileName.charAt(0).toUpperCase();
|
|
53
|
+
exportAsDefaultInterfaceName = `I${firstCharUpperCased}${normalizedFileName.slice(1)}`;
|
|
54
|
+
if (!exportAsDefaultInterfaceName.endsWith('strings') &&
|
|
55
|
+
!exportAsDefaultInterfaceName.endsWith('Strings')) {
|
|
56
|
+
exportAsDefaultInterfaceName += 'Strings';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
typings,
|
|
61
|
+
exportAsDefaultInterfaceName
|
|
62
|
+
};
|
|
41
63
|
}
|
|
42
64
|
});
|
|
43
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypingsGenerator.js","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,
|
|
1
|
+
{"version":3,"file":"TypingsGenerator.js","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAKsC;AAItC,mDAA+C;AAiC/C;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,gDAA4B;IAChE,YAAmB,OAAiC;QAClD,MAAM,EACJ,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,eAAe,EAChB,GAAG,OAAO,CAAC;QACZ,MAAM,2CAA2C,GAC/C,OAAO,eAAe,KAAK,QAAQ;YACjC,CAAC,CAAE,eAA6D,CAAC,8BAA8B;YAC/F,CAAC,CAAC,SAAS,CAAC;QAChB,KAAK,CAAC;YACJ,GAAG,OAAO;YACV,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,CAAC;YAChE,uBAAuB,EAAE,CAAC,OAAe,EAAE,QAAgB,EAAE,gBAAwB,EAAE,EAAE;gBACvF,MAAM,WAAW,GAAsB,IAAA,4BAAY,EAAC;oBAClD,QAAQ;oBACR,OAAO;oBACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,wBAAwB;oBACxB,yBAAyB;oBACzB,YAAY;iBACb,CAAC,CAAC;gBAEH,MAAM,OAAO,GAAyB,EAAE,CAAC;gBAEzC,wCAAwC;gBACxC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;oBACrC,IAAI,OAAO,GAAuB,WAAW,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;oBAClE,IAAI,cAAc,EAAE,CAAC;wBACnB,OAAO,GAAG,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;oBAClE,CAAC;oBAED,OAAO,CAAC,IAAI,CAAC;wBACX,UAAU,EAAE,UAAU;wBACtB,OAAO;qBACR,CAAC,CAAC;gBACL,CAAC;gBAED,IAAI,4BAAgD,CAAC;gBACrD,IAAI,2CAA2C,EAAE,CAAC;oBAChD,MAAM,cAAc,GAAW,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC/F,IAAI,cAAc,GAAW,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;oBACvD,IAAI,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;wBAC7D,cAAc,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC;oBACjE,CAAC;oBAED,MAAM,wBAAwB,GAAW,QAAQ,CAAC,SAAS,CAAC,cAAc,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC;oBAChG,MAAM,kBAAkB,GAAW,wBAAwB,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;oBAC3F,MAAM,mBAAmB,GAAW,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;oBAC/E,4BAA4B,GAAG,IAAI,mBAAmB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;oBAEvF,IACE,CAAC,4BAA4B,CAAC,QAAQ,CAAC,SAAS,CAAC;wBACjD,CAAC,4BAA4B,CAAC,QAAQ,CAAC,SAAS,CAAC,EACjD,CAAC;wBACD,4BAA4B,IAAI,SAAS,CAAC;oBAC5C,CAAC;gBACH,CAAC;gBAED,OAAO;oBACL,OAAO;oBACP,4BAA4B;iBAC7B,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AArED,4CAqEC","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 IExportAsDefaultOptions,\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 IInferInterfaceNameExportAsDefaultOptions\n extends Omit<IExportAsDefaultOptions, 'interfaceName'> {\n /**\n * When `exportAsDefault` is true and this option is true, the default export interface name will be inferred\n * from the filename.\n */\n inferInterfaceNameFromFilename?: boolean;\n}\n\n/**\n * @public\n */\nexport interface ITypingsGeneratorOptions extends ITypingsGeneratorBaseOptions {\n exportAsDefault?: boolean | IExportAsDefaultOptions | IInferInterfaceNameExportAsDefaultOptions;\n\n resxNewlineNormalization?: NewlineKind | undefined;\n\n ignoreMissingResxComments?: boolean | undefined;\n\n ignoreString?: IgnoreStringFunction;\n\n processComment?: (\n comment: string | undefined,\n relativeFilePath: 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 {\n ignoreString,\n processComment,\n resxNewlineNormalization,\n ignoreMissingResxComments,\n exportAsDefault\n } = options;\n const inferDefaultExportInterfaceNameFromFilename: boolean | undefined =\n typeof exportAsDefault === 'object'\n ? (exportAsDefault as IInferInterfaceNameExportAsDefaultOptions).inferInterfaceNameFromFilename\n : undefined;\n super({\n ...options,\n fileExtensions: ['.resx', '.resx.json', '.loc.json', '.resjson'],\n parseAndGenerateTypings: (content: string, filePath: string, relativeFilePath: string) => {\n const locFileData: ILocalizationFile = parseLocFile({\n filePath,\n content,\n terminal: this.terminal,\n resxNewlineNormalization,\n 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, relativeFilePath, stringName);\n }\n\n typings.push({\n exportName: stringName,\n comment\n });\n }\n\n let exportAsDefaultInterfaceName: string | undefined;\n if (inferDefaultExportInterfaceNameFromFilename) {\n const lastSlashIndex: number = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\\\'));\n let extensionIndex: number = filePath.lastIndexOf('.');\n if (filePath.slice(extensionIndex).toLowerCase() === '.json') {\n extensionIndex = filePath.lastIndexOf('.', extensionIndex - 1);\n }\n\n const fileNameWithoutExtension: string = filePath.substring(lastSlashIndex + 1, extensionIndex);\n const normalizedFileName: string = fileNameWithoutExtension.replace(/[^a-zA-Z0-9$_]/g, '');\n const firstCharUpperCased: string = normalizedFileName.charAt(0).toUpperCase();\n exportAsDefaultInterfaceName = `I${firstCharUpperCased}${normalizedFileName.slice(1)}`;\n\n if (\n !exportAsDefaultInterfaceName.endsWith('strings') &&\n !exportAsDefaultInterfaceName.endsWith('Strings')\n ) {\n exportAsDefaultInterfaceName += 'Strings';\n }\n }\n\n return {\n typings,\n exportAsDefaultInterfaceName\n };\n }\n });\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export { parseLocJson } from './parsers/parseLocJson';
|
|
|
8
8
|
export { parseResJson } from './parsers/parseResJson';
|
|
9
9
|
export { parseResx, type IParseResxOptions, type IParseResxOptionsBase } from './parsers/parseResx';
|
|
10
10
|
export { parseLocFile, type IParseLocFileOptions, type ParserKind } from './LocFileParser';
|
|
11
|
-
export { type ITypingsGeneratorOptions, TypingsGenerator } from './TypingsGenerator';
|
|
11
|
+
export { type ITypingsGeneratorOptions, type IInferInterfaceNameExportAsDefaultOptions, TypingsGenerator } from './TypingsGenerator';
|
|
12
12
|
export { getPseudolocalizer } from './Pseudolocalization';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,yCAAyC,EAC9C,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
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,iDAAoG;AAA3F,sGAAA,SAAS,OAAA;AAClB,iDAA2F;AAAlF,6GAAA,YAAY,OAAA;AACrB,
|
|
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,iDAAoG;AAA3F,sGAAA,SAAS,OAAA;AAClB,iDAA2F;AAAlF,6GAAA,YAAY,OAAA;AACrB,uDAI4B;AAD1B,oHAAA,gBAAgB,OAAA;AAElB,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, type IParseResxOptions, type IParseResxOptionsBase } from './parsers/parseResx';\nexport { parseLocFile, type IParseLocFileOptions, type ParserKind } from './LocFileParser';\nexport {\n type ITypingsGeneratorOptions,\n type IInferInterfaceNameExportAsDefaultOptions,\n TypingsGenerator\n} from './TypingsGenerator';\nexport { getPseudolocalizer } from './Pseudolocalization';\n"]}
|
|
@@ -15,7 +15,7 @@ const LOC_JSON_SCHEMA = node_core_library_1.JsonSchema.fromLoadedObject(locJson_
|
|
|
15
15
|
function parseLocJson({ content, filePath, ignoreString }) {
|
|
16
16
|
const parsedFile = node_core_library_1.JsonFile.parseString(content);
|
|
17
17
|
try {
|
|
18
|
-
LOC_JSON_SCHEMA.validateObject(parsedFile, filePath);
|
|
18
|
+
LOC_JSON_SCHEMA.validateObject(parsedFile, filePath, { ignoreSchemaField: true });
|
|
19
19
|
}
|
|
20
20
|
catch (e) {
|
|
21
21
|
throw new Error(`The loc file is invalid. Error: ${e}`);
|
|
@@ -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,CAAC;QACH,eAAe,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;
|
|
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,CAAC;QACH,eAAe,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IACpF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,aAAa,GAAsB,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;gBACjC,aAAa,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;YAClC,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,OAAO,UAAU,CAAC;IACpB,CAAC;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, { ignoreSchemaField: true });\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"]}
|
|
@@ -2,14 +2,8 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
3
|
"title": "Localizable JSON file",
|
|
4
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
5
|
"patternProperties": {
|
|
12
|
-
"^[A-Za-z_][0-9A-Za-z_]*$": {
|
|
6
|
+
"^[A-Za-z_$][0-9A-Za-z_$]*$": {
|
|
13
7
|
"type": "object",
|
|
14
8
|
"properties": {
|
|
15
9
|
"value": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/localization-utilities",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
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",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"pseudolocale": "~1.1.0",
|
|
15
15
|
"xmldoc": "~1.1.2",
|
|
16
|
-
"@rushstack/node-core-library": "5.
|
|
17
|
-
"@rushstack/terminal": "0.
|
|
18
|
-
"@rushstack/typings-generator": "0.
|
|
16
|
+
"@rushstack/node-core-library": "5.7.0",
|
|
17
|
+
"@rushstack/terminal": "0.14.0",
|
|
18
|
+
"@rushstack/typings-generator": "0.13.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/xmldoc": "1.1.4",
|
|
22
|
-
"@rushstack/heft": "0.
|
|
22
|
+
"@rushstack/heft": "0.67.0",
|
|
23
23
|
"local-node-rig": "1.0.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|