@twin.org/validate-locales 0.0.2-next.21

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.
@@ -0,0 +1,216 @@
1
+ {
2
+ "error": {
3
+ "commands": {
4
+ "common": {
5
+ "missingEnv": "The \"{option}\" option is configured as an environment variable, but there is no environment variable with the name \"{value}\" set.",
6
+ "optionInvalidHex": "The \"{option}\" does not appear to be hex. \"{value}\"",
7
+ "optionInvalidBase64": "The \"{option}\" does not appear to be base64. \"{value}\"",
8
+ "optionInvalidHexBase64": "The \"{option}\" does not appear to be hex or base64. \"{value}\"",
9
+ "optionMinValue": "The \"{option}\" option must be greater than or equal to {minValue}, it is {value}.",
10
+ "optionMaxValue": "The \"{option}\" option must be less than or equal to {maxValue}, it is {value}."
11
+ }
12
+ },
13
+ "validation": {
14
+ "beEmpty": "{fieldName} must be empty",
15
+ "beNotEmpty": "{fieldName} must not be empty",
16
+ "beText": "{fieldName} must be text",
17
+ "beTextValue": "{fieldName} must contain some text",
18
+ "beTextMinMax": "{fieldName} must be longer than {minLength} and shorter than {maxLength} characters",
19
+ "beTextMin": "{fieldName} must be longer than {minLength} characters",
20
+ "beTextMax": "{fieldName} must be shorter than {maxLength} characters",
21
+ "beTextBase58": "{fieldName} must be text formatted using Base58 characters",
22
+ "beTextBase64": "{fieldName} must be text formatted using Base64 characters",
23
+ "beTextHex": "{fieldName} must be text formatted using Hex characters",
24
+ "beTextRegExp": "{fieldName} must be text formatted using the matching pattern {format}",
25
+ "beNumber": "{fieldName} must be a number",
26
+ "beNumberMinMax": "{fieldName} must be >= {minValue} and <= {maxValue}",
27
+ "beNumberMin": "{fieldName} must be >= {minValue}",
28
+ "beNumberMax": "{fieldName} must be <= {maxValue}",
29
+ "beWholeNumber": "{fieldName} must be a whole number",
30
+ "beWholeNumberMinMax": "{fieldName} must be a whole number >= {minValue} and <= {maxValue}",
31
+ "beWholeNumberMin": "{fieldName} must be a whole number >= {minValue}",
32
+ "beWholeNumberMax": "{fieldName} must be a whole number <= {maxValue}",
33
+ "beBigInteger": "{fieldName} must be a bigint",
34
+ "beBigIntegerMinMax": "{fieldName} must be a bigint >= {minValue} and <= {maxValue}",
35
+ "beBigIntegerMin": "{fieldName} must be a bigint >= {minValue}",
36
+ "beBigIntegerMax": "{fieldName} must be a bigint <= {maxValue}",
37
+ "beBoolean": "{fieldName} must be true or false",
38
+ "beDate": "{fieldName} must be a date",
39
+ "beDateTime": "{fieldName} must be a date/time",
40
+ "beTime": "{fieldName} must be a time",
41
+ "beTimestampMilliseconds": "{fieldName} must be a timestamp in milliseconds",
42
+ "beTimestampSeconds": "{fieldName} must be a timestamp in seconds",
43
+ "beObject": "{fieldName} must be an object",
44
+ "beArray": "{fieldName} must be an array",
45
+ "beArrayValue": "{fieldName} must be an array with at least one item",
46
+ "beIncluded": "{fieldName} is unrecognised",
47
+ "beByteArray": "{fieldName} must be a byte array",
48
+ "beUrn": "{fieldName} must be a correctly formatted urn",
49
+ "beUrl": "{fieldName} must be a correctly formatted url",
50
+ "beJSON": "{fieldName} must be correctly formatted JSON",
51
+ "beEmail": "{fieldName} must be a correctly formatted e-mail address"
52
+ },
53
+ "guard": {
54
+ "undefined": "Property \"{property}\" must be defined, it is \"{value}\"",
55
+ "string": "Property \"{property}\" must be a string, it is \"{value}\"",
56
+ "stringEmpty": "Property \"{property}\" must have a value, it is empty",
57
+ "stringBase64": "Property \"{property}\" must be a base64 encoded string, it is \"{value}\"",
58
+ "stringBase64Url": "Property \"{property}\" must be a base64 url encoded string, it is \"{value}\"",
59
+ "stringBase58": "Property \"{property}\" must be a base58 encoded string, it is \"{value}\"",
60
+ "stringHex": "Property \"{property}\" must be a hex string, it is \"{value}\"",
61
+ "stringHexLength": "Property \"{property}\" must be a hex string of length \"{options}\", it is \"{value}\"",
62
+ "stringJson": "Property \"{property}\" must be a JSON string",
63
+ "number": "Property \"{property}\" must be a number, it is \"{value}\"",
64
+ "integer": "Property \"{property}\" must be an integer, it is \"{value}\"",
65
+ "bigint": "Property \"{property}\" must be a bigint, it is \"{value}\"",
66
+ "boolean": "Property \"{property}\" must be a boolean, it is \"{value}\"",
67
+ "date": "Property \"{property}\" must be a date, it is \"{value}\"",
68
+ "timestampMilliseconds": "Property \"{property}\" must be a timestamp in milliseconds, it is \"{value}\"",
69
+ "timestampSeconds": "Property \"{property}\" must be a timestamp in seconds, it is \"{value}\"",
70
+ "objectUndefined": "Property \"{property}\" must be an object, it is \"undefined\"",
71
+ "object": "Property \"{property}\" must be an object, it is \"{value}\"",
72
+ "objectValue": "Property \"{property}\" must be an object, with at least one property, it is \"{value}\"",
73
+ "array": "Property \"{property}\" must be an array, it is \"{value}\"",
74
+ "arrayValue": "Property \"{property}\" must be an array with at least one item",
75
+ "arrayOneOf": "Property \"{property}\" must be one of [{options}], it is \"{value}\"",
76
+ "arrayStartsWith": "Property \"{property}\" must be an array starting with [{startValues}], it is \"{value}\"",
77
+ "arrayEndsWith": "Property \"{property}\" must be an array ending with [{endValues}], it is \"{value}\"",
78
+ "uint8Array": "Property \"{property}\" must be a Uint8Array, it is \"{value}\"",
79
+ "function": "Property \"{property}\" must be a function, it is \"{value}\"",
80
+ "urn": "Property \"{property}\" must be a Urn formatted string, it is \"{value}\"",
81
+ "url": "Property \"{property}\" must be a Url formatted string, it is \"{value}\"",
82
+ "email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\""
83
+ },
84
+ "objectHelper": {
85
+ "failedBytesToJSON": "Failed converting bytes to JSON",
86
+ "cannotSetArrayIndex": "Cannot set property \"{property}\" using index \"{index}\" as it is not an array",
87
+ "cannotSetProperty": "Cannot set property \"{property}\" when the target is not an object"
88
+ },
89
+ "common": {
90
+ "notImplementedMethod": "The method \"{method}\" has not been implemented",
91
+ "validation": "Validation failed"
92
+ },
93
+ "factory": {
94
+ "noUnregister": "There is no {typeName} registered with the name \"{name}\"",
95
+ "noGet": "The requested {typeName} \"{name}\" does not exist in the factory"
96
+ },
97
+ "bitString": {
98
+ "outOfRange": "The index should be >= 0 and less than the length of the bit string, the index is \"{index}\" and the number of bit is \"{numberBits}\""
99
+ },
100
+ "base32": {
101
+ "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
102
+ },
103
+ "base64": {
104
+ "length4Multiple": "Invalid length should be a multiple of 4, it is \"{value}\""
105
+ },
106
+ "base58": {
107
+ "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
108
+ },
109
+ "jsonHelper": {
110
+ "failedPatch": "Failed to patch the JSON object, patch index \"{index}\" failed"
111
+ },
112
+ "validateLocales": {
113
+ "validationFailed": "Validation failed.",
114
+ "unusedLocaleEntry": "Locale entry \"{key}\" is not used in the source files.",
115
+ "usesSingleQuotes": "Locale entry \"{key}\" uses single quotes around a parameter. Use double quotes otherwise the value will not be substituted correctly.",
116
+ "missingLocaleEntry": "Locale entry \"{key}\" is missing from the locale file it is referenced in source file \"{source}:{line}:{column}\".",
117
+ "unableToProcessContent": "Unable to process content \"{content}\".",
118
+ "missingPropertyInLocale": "Missing property \"{property}\" when referencing key \"{key}\" in source file \"{source}:{line}:{column}\"."
119
+ }
120
+ },
121
+ "warn": {
122
+ "common": {
123
+ "devOnlyTool": "This tool is intended to be used for development purposes, it is not recommended for use in production scenarios."
124
+ }
125
+ },
126
+ "cli": {
127
+ "progress": {
128
+ "done": "Done.",
129
+ "error": "Error",
130
+ "loadingEnvFiles": "Loading env files",
131
+ "pleaseWait": "Please wait...",
132
+ "writingJsonFile": "Writing JSON file",
133
+ "writingEnvFile": "Writing env file",
134
+ "readingJsonFile": "Reading JSON file",
135
+ "readingEnvFile": "Reading env file"
136
+ },
137
+ "options": {
138
+ "lang": {
139
+ "param": "--lang '<'lang'>'",
140
+ "description": "The language to display the output in."
141
+ },
142
+ "load-env": {
143
+ "param": "--load-env [env...]",
144
+ "description": "Load the env files to initialise any environment variables."
145
+ },
146
+ "no-console": {
147
+ "param": "--no-console",
148
+ "description": "Hides the output in the console."
149
+ },
150
+ "json": {
151
+ "param": "--json '<'filename'>'",
152
+ "description": "Creates a JSON file containing the output."
153
+ },
154
+ "env": {
155
+ "param": "--env '<'filename'>'",
156
+ "description": "Creates an env file containing the output."
157
+ },
158
+ "merge-json": {
159
+ "param": "--merge-json",
160
+ "description": "If the JSON file already exists merge the data instead of overwriting."
161
+ },
162
+ "merge-env": {
163
+ "param": "--merge-env",
164
+ "description": "If the env file already exists merge the data instead of overwriting."
165
+ }
166
+ }
167
+ },
168
+ "errorNames": {
169
+ "error": "Error",
170
+ "generalError": "General",
171
+ "guardError": "Guard",
172
+ "conflictError": "Conflict",
173
+ "notFoundError": "Not Found",
174
+ "notSupportedError": "Not Supported",
175
+ "alreadyExistsError": "Already Exists",
176
+ "notImplementedError": "Not Implemented",
177
+ "validationError": "Validation",
178
+ "unprocessableError": "Unprocessable",
179
+ "unauthorizedError": "Unauthorized"
180
+ },
181
+ "validation": {
182
+ "defaultFieldName": "The field"
183
+ },
184
+ "commands": {
185
+ "validate-locales": {
186
+ "options": {
187
+ "source": {
188
+ "param": "--source '<'glob'>'",
189
+ "description": "Glob for the source files to check."
190
+ },
191
+ "locales": {
192
+ "param": "--locales '<'glob'>'",
193
+ "description": "Glob for the locale files to check."
194
+ },
195
+ "ignoreFile": {
196
+ "param": "--ignoreFile <'path'>",
197
+ "description": "File containing keys to ignore."
198
+ }
199
+ },
200
+ "progress": {
201
+ "validatingLocale": "Validating locale: {localeFile}"
202
+ },
203
+ "labels": {
204
+ "source": "Source",
205
+ "locales": "Locales",
206
+ "ignoreFile": "Ignore file",
207
+ "noMissingLocaleEntries": "✅ No missing locale entries found",
208
+ "noUnusedLocaleEntries": "✅ No unused locale entries found"
209
+ },
210
+ "warnings": {
211
+ "noSourceFiles": "No source files found to validate.",
212
+ "noLocaleFiles": "No locale files found to validate."
213
+ }
214
+ }
215
+ }
216
+ }
@@ -0,0 +1,23 @@
1
+ import { CLIBase } from "@twin.org/cli-core";
2
+ import type { Command } from "commander";
3
+ /**
4
+ * The main entry point for the CLI.
5
+ */
6
+ export declare class CLI extends CLIBase {
7
+ /**
8
+ * Run the app.
9
+ * @param argv The process arguments.
10
+ * @param localesDirectory The directory for the locales, default to relative to the script.
11
+ * @param options Additional options.
12
+ * @param options.overrideOutputWidth Override the output width.
13
+ * @returns The exit code.
14
+ */
15
+ run(argv: string[], localesDirectory?: string, options?: {
16
+ overrideOutputWidth?: number;
17
+ }): Promise<number>;
18
+ /**
19
+ * Configure any options or actions at the root program level.
20
+ * @param program The root program command.
21
+ */
22
+ protected configureRoot(program: Command): void;
23
+ }
@@ -0,0 +1,18 @@
1
+ import type { Command } from "commander";
2
+ /**
3
+ * Build the root command to be consumed by the CLI.
4
+ * @param program The command to build on.
5
+ */
6
+ export declare function buildCommandValidateLocales(program: Command): void;
7
+ /**
8
+ * Action the root command.
9
+ * @param opts The options for the command.
10
+ * @param opts.source The source glob.
11
+ * @param opts.locales The locales glob.
12
+ * @param opts.ignoreFile The ignore file path.
13
+ */
14
+ export declare function actionCommandValidateLocales(opts: {
15
+ source: string;
16
+ locales: string;
17
+ ignoreFile: string;
18
+ }): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export * from "./cli";
2
+ export * from "./commands/validateLocales";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Model for a locale dictionary entry.
3
+ */
4
+ export interface ILocaleDictionaryEntry {
5
+ /**
6
+ * The locale.
7
+ */
8
+ locale: string;
9
+ /**
10
+ * The key.
11
+ */
12
+ key: string;
13
+ /**
14
+ * The value.
15
+ */
16
+ value: string;
17
+ /**
18
+ * The property names.
19
+ */
20
+ propertyNames: string[];
21
+ /**
22
+ * Whether the entry is referenced in the source code.
23
+ */
24
+ referenced: boolean;
25
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Model for a locale dictionary missing reference.
3
+ */
4
+ export interface ILocaleMissingReference {
5
+ /**
6
+ * The type of the missing reference.
7
+ */
8
+ type: string;
9
+ /**
10
+ * The key of the missing reference.
11
+ */
12
+ key: string;
13
+ /**
14
+ * The source file for the missing reference.
15
+ */
16
+ source: string;
17
+ /**
18
+ * The line number for the missing reference.
19
+ */
20
+ line: number;
21
+ /**
22
+ * The column number for the missing reference.
23
+ */
24
+ column: number;
25
+ }
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ## [0.0.2-next.21](https://github.com/twinfoundation/framework/compare/validate-locales-v0.0.2-next.20...validate-locales-v0.0.2-next.21) (2025-10-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/cli-core bumped from 0.0.2-next.20 to 0.0.2-next.21
16
+ * @twin.org/core bumped from 0.0.2-next.20 to 0.0.2-next.21
17
+ * @twin.org/nameof bumped from 0.0.2-next.20 to 0.0.2-next.21
18
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.20 to 0.0.2-next.21
19
+ * devDependencies
20
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.20 to 0.0.2-next.21
21
+
22
+ ## @twin.org/validate-locales - Changelog
@@ -0,0 +1,15 @@
1
+ # @twin.org/validate-locales - Examples
2
+
3
+ ## Command Line Tool
4
+
5
+ First install the tool with the following script.
6
+
7
+ ```shell
8
+ npm install @twin.org/validate-locales
9
+ ```
10
+
11
+ You can then run the tool from the command line e.g.
12
+
13
+ ```shell
14
+ validate-locales
15
+ ```
@@ -0,0 +1,83 @@
1
+ # Class: CLI
2
+
3
+ The main entry point for the CLI.
4
+
5
+ ## Extends
6
+
7
+ - `CLIBase`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new CLI**(): `CLI`
14
+
15
+ #### Returns
16
+
17
+ `CLI`
18
+
19
+ #### Inherited from
20
+
21
+ `CLIBase.constructor`
22
+
23
+ ## Methods
24
+
25
+ ### run()
26
+
27
+ > **run**(`argv`, `localesDirectory?`, `options?`): `Promise`\<`number`\>
28
+
29
+ Run the app.
30
+
31
+ #### Parameters
32
+
33
+ ##### argv
34
+
35
+ `string`[]
36
+
37
+ The process arguments.
38
+
39
+ ##### localesDirectory?
40
+
41
+ `string`
42
+
43
+ The directory for the locales, default to relative to the script.
44
+
45
+ ##### options?
46
+
47
+ Additional options.
48
+
49
+ ###### overrideOutputWidth?
50
+
51
+ `number`
52
+
53
+ Override the output width.
54
+
55
+ #### Returns
56
+
57
+ `Promise`\<`number`\>
58
+
59
+ The exit code.
60
+
61
+ ***
62
+
63
+ ### configureRoot()
64
+
65
+ > `protected` **configureRoot**(`program`): `void`
66
+
67
+ Configure any options or actions at the root program level.
68
+
69
+ #### Parameters
70
+
71
+ ##### program
72
+
73
+ `Command`
74
+
75
+ The root program command.
76
+
77
+ #### Returns
78
+
79
+ `void`
80
+
81
+ #### Overrides
82
+
83
+ `CLIBase.configureRoot`
@@ -0,0 +1,33 @@
1
+ # Function: actionCommandValidateLocales()
2
+
3
+ > **actionCommandValidateLocales**(`opts`): `Promise`\<`void`\>
4
+
5
+ Action the root command.
6
+
7
+ ## Parameters
8
+
9
+ ### opts
10
+
11
+ The options for the command.
12
+
13
+ #### source
14
+
15
+ `string`
16
+
17
+ The source glob.
18
+
19
+ #### locales
20
+
21
+ `string`
22
+
23
+ The locales glob.
24
+
25
+ #### ignoreFile
26
+
27
+ `string`
28
+
29
+ The ignore file path.
30
+
31
+ ## Returns
32
+
33
+ `Promise`\<`void`\>
@@ -0,0 +1,17 @@
1
+ # Function: buildCommandValidateLocales()
2
+
3
+ > **buildCommandValidateLocales**(`program`): `void`
4
+
5
+ Build the root command to be consumed by the CLI.
6
+
7
+ ## Parameters
8
+
9
+ ### program
10
+
11
+ `Command`
12
+
13
+ The command to build on.
14
+
15
+ ## Returns
16
+
17
+ `void`
@@ -0,0 +1,10 @@
1
+ # @twin.org/validate-locales
2
+
3
+ ## Classes
4
+
5
+ - [CLI](classes/CLI.md)
6
+
7
+ ## Functions
8
+
9
+ - [buildCommandValidateLocales](functions/buildCommandValidateLocales.md)
10
+ - [actionCommandValidateLocales](functions/actionCommandValidateLocales.md)
@@ -0,0 +1,2 @@
1
+ ===>
2
+ <===
@@ -0,0 +1,44 @@
1
+ {
2
+ "error": {
3
+ "validateLocales": {
4
+ "validationFailed": "Validation failed.",
5
+ "unusedLocaleEntry": "Locale entry \"{key}\" is not used in the source files.",
6
+ "usesSingleQuotes": "Locale entry \"{key}\" uses single quotes around a parameter. Use double quotes otherwise the value will not be substituted correctly.",
7
+ "missingLocaleEntry": "Locale entry \"{key}\" is missing from the locale file it is referenced in source file \"{source}:{line}:{column}\".",
8
+ "unableToProcessContent": "Unable to process content \"{content}\".",
9
+ "missingPropertyInLocale": "Missing property \"{property}\" when referencing key \"{key}\" in source file \"{source}:{line}:{column}\"."
10
+ }
11
+ },
12
+ "commands": {
13
+ "validate-locales": {
14
+ "options": {
15
+ "source": {
16
+ "param": "--source '<'glob'>'",
17
+ "description": "Glob for the source files to check."
18
+ },
19
+ "locales": {
20
+ "param": "--locales '<'glob'>'",
21
+ "description": "Glob for the locale files to check."
22
+ },
23
+ "ignoreFile": {
24
+ "param": "--ignoreFile <'path'>",
25
+ "description": "File containing keys to ignore."
26
+ }
27
+ },
28
+ "progress": {
29
+ "validatingLocale": "Validating locale: {localeFile}"
30
+ },
31
+ "labels": {
32
+ "source": "Source",
33
+ "locales": "Locales",
34
+ "ignoreFile": "Ignore file",
35
+ "noMissingLocaleEntries": "✅ No missing locale entries found",
36
+ "noUnusedLocaleEntries": "✅ No unused locale entries found"
37
+ },
38
+ "warnings": {
39
+ "noSourceFiles": "No source files found to validate.",
40
+ "noLocaleFiles": "No locale files found to validate."
41
+ }
42
+ }
43
+ }
44
+ }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@twin.org/validate-locales",
3
+ "version": "0.0.2-next.21",
4
+ "description": "Tool to validate source files against the locales",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/framework.git",
8
+ "directory": "apps/validate-locales"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "dependencies": {
17
+ "@twin.org/cli-core": "0.0.2-next.21",
18
+ "@twin.org/core": "0.0.2-next.21",
19
+ "@twin.org/nameof": "0.0.2-next.21",
20
+ "@twin.org/nameof-transformer": "0.0.2-next.21",
21
+ "commander": "14.0.1",
22
+ "glob": "11.0.3",
23
+ "typescript": "5.9.2"
24
+ },
25
+ "main": "./dist/cjs/index.cjs",
26
+ "module": "./dist/esm/index.mjs",
27
+ "types": "./dist/types/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/types/index.d.ts",
31
+ "require": "./dist/cjs/index.cjs",
32
+ "import": "./dist/esm/index.mjs"
33
+ }
34
+ },
35
+ "files": [
36
+ "bin",
37
+ "dist/cjs",
38
+ "dist/esm",
39
+ "dist/locales",
40
+ "dist/types",
41
+ "locales",
42
+ "docs"
43
+ ],
44
+ "bin": {
45
+ "validate-locales": "bin/index.js"
46
+ },
47
+ "directories": {
48
+ "doc": "docs",
49
+ "test": "tests"
50
+ },
51
+ "bugs": {
52
+ "url": "git+https://github.com/twinfoundation/framework/issues"
53
+ },
54
+ "homepage": "https://twindev.org",
55
+ "keywords": [
56
+ "twin",
57
+ "trade",
58
+ "iota",
59
+ "framework",
60
+ "blockchain"
61
+ ]
62
+ }