@o3r/transloco 0.0.0 → 14.5.0-prerelease.1

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.
Files changed (122) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +64 -0
  3. package/builders/helpers/localization-generator.d.ts +126 -0
  4. package/builders/helpers/localization-generator.d.ts.map +1 -0
  5. package/builders/helpers/localization-generator.js +303 -0
  6. package/builders/helpers/localization-generator.js.map +1 -0
  7. package/builders/i18n/index.d.ts +7 -0
  8. package/builders/i18n/index.d.ts.map +1 -0
  9. package/builders/i18n/index.js +39 -0
  10. package/builders/i18n/index.js.map +1 -0
  11. package/builders/i18n/schema.d.ts +30 -0
  12. package/builders/i18n/schema.d.ts.map +1 -0
  13. package/builders/i18n/schema.js +3 -0
  14. package/builders/i18n/schema.js.map +1 -0
  15. package/builders/i18n/schema.json +35 -0
  16. package/builders/localization/index.d.ts +23 -0
  17. package/builders/localization/index.d.ts.map +1 -0
  18. package/builders/localization/index.js +416 -0
  19. package/builders/localization/index.js.map +1 -0
  20. package/builders/localization/schema.d.ts +29 -0
  21. package/builders/localization/schema.d.ts.map +1 -0
  22. package/builders/localization/schema.js +3 -0
  23. package/builders/localization/schema.js.map +1 -0
  24. package/builders/localization/schema.json +78 -0
  25. package/builders/localization-extractor/index.d.ts +8 -0
  26. package/builders/localization-extractor/index.d.ts.map +1 -0
  27. package/builders/localization-extractor/index.js +181 -0
  28. package/builders/localization-extractor/index.js.map +1 -0
  29. package/builders/localization-extractor/schema.d.ts +25 -0
  30. package/builders/localization-extractor/schema.d.ts.map +1 -0
  31. package/builders/localization-extractor/schema.js +3 -0
  32. package/builders/localization-extractor/schema.js.map +1 -0
  33. package/builders/localization-extractor/schema.json +62 -0
  34. package/builders/localization-extractor/validations.d.ts +17 -0
  35. package/builders/localization-extractor/validations.d.ts.map +1 -0
  36. package/builders/localization-extractor/validations.js +54 -0
  37. package/builders/localization-extractor/validations.js.map +1 -0
  38. package/builders/metadata-check/helpers/index.d.ts +2 -0
  39. package/builders/metadata-check/helpers/index.d.ts.map +1 -0
  40. package/builders/metadata-check/helpers/index.js +5 -0
  41. package/builders/metadata-check/helpers/index.js.map +1 -0
  42. package/builders/metadata-check/helpers/localization-metadata-comparison-helper.d.ts +14 -0
  43. package/builders/metadata-check/helpers/localization-metadata-comparison-helper.d.ts.map +1 -0
  44. package/builders/metadata-check/helpers/localization-metadata-comparison-helper.js +34 -0
  45. package/builders/metadata-check/helpers/localization-metadata-comparison-helper.js.map +1 -0
  46. package/builders/metadata-check/index.d.ts +7 -0
  47. package/builders/metadata-check/index.d.ts.map +1 -0
  48. package/builders/metadata-check/index.js +12 -0
  49. package/builders/metadata-check/index.js.map +1 -0
  50. package/builders/metadata-check/schema.d.ts +5 -0
  51. package/builders/metadata-check/schema.d.ts.map +1 -0
  52. package/builders/metadata-check/schema.js +3 -0
  53. package/builders/metadata-check/schema.js.map +1 -0
  54. package/builders/metadata-check/schema.json +46 -0
  55. package/builders/package.json +3 -0
  56. package/builders.json +25 -0
  57. package/collection.json +29 -0
  58. package/fesm2022/o3r-transloco-rules-engine.mjs +57 -0
  59. package/fesm2022/o3r-transloco-rules-engine.mjs.map +1 -0
  60. package/fesm2022/o3r-transloco.mjs +1177 -0
  61. package/fesm2022/o3r-transloco.mjs.map +1 -0
  62. package/package.json +190 -2
  63. package/rules-engine/package.json +4 -0
  64. package/schemas/localization.metadata.schema.json +84 -0
  65. package/schemas/localization.schema.json +116 -0
  66. package/schemas/rules-engine.localization-action.schema.json +26 -0
  67. package/schematics/add-localization-key/index.d.ts +13 -0
  68. package/schematics/add-localization-key/index.d.ts.map +1 -0
  69. package/schematics/add-localization-key/index.js +227 -0
  70. package/schematics/add-localization-key/index.js.map +1 -0
  71. package/schematics/add-localization-key/schema.d.ts +20 -0
  72. package/schematics/add-localization-key/schema.d.ts.map +1 -0
  73. package/schematics/add-localization-key/schema.js +3 -0
  74. package/schematics/add-localization-key/schema.js.map +1 -0
  75. package/schematics/add-localization-key/schema.json +49 -0
  76. package/schematics/cms-adapter/index.d.ts +8 -0
  77. package/schematics/cms-adapter/index.d.ts.map +1 -0
  78. package/schematics/cms-adapter/index.js +81 -0
  79. package/schematics/cms-adapter/index.js.map +1 -0
  80. package/schematics/localization-base/index.d.ts +14 -0
  81. package/schematics/localization-base/index.d.ts.map +1 -0
  82. package/schematics/localization-base/index.js +359 -0
  83. package/schematics/localization-base/index.js.map +1 -0
  84. package/schematics/localization-base/templates/src/assets/locales/__empty__.gitkeep +0 -0
  85. package/schematics/localization-to-component/index.d.ts +13 -0
  86. package/schematics/localization-to-component/index.d.ts.map +1 -0
  87. package/schematics/localization-to-component/index.js +264 -0
  88. package/schematics/localization-to-component/index.js.map +1 -0
  89. package/schematics/localization-to-component/schema.d.ts +12 -0
  90. package/schematics/localization-to-component/schema.d.ts.map +1 -0
  91. package/schematics/localization-to-component/schema.js +3 -0
  92. package/schematics/localization-to-component/schema.js.map +1 -0
  93. package/schematics/localization-to-component/schema.json +31 -0
  94. package/schematics/localization-to-component/templates/__name__-localization.json +3 -0
  95. package/schematics/localization-to-component/templates/__name__-translation.ts.template +5 -0
  96. package/schematics/migration-localization-to-transloco/index.d.ts +8 -0
  97. package/schematics/migration-localization-to-transloco/index.d.ts.map +1 -0
  98. package/schematics/migration-localization-to-transloco/index.js +194 -0
  99. package/schematics/migration-localization-to-transloco/index.js.map +1 -0
  100. package/schematics/migration-localization-to-transloco/schema.d.ts +15 -0
  101. package/schematics/migration-localization-to-transloco/schema.d.ts.map +1 -0
  102. package/schematics/migration-localization-to-transloco/schema.js +3 -0
  103. package/schematics/migration-localization-to-transloco/schema.js.map +1 -0
  104. package/schematics/migration-localization-to-transloco/schema.json +30 -0
  105. package/schematics/ng-add/helpers/devtools-registration.d.ts +8 -0
  106. package/schematics/ng-add/helpers/devtools-registration.d.ts.map +1 -0
  107. package/schematics/ng-add/helpers/devtools-registration.js +37 -0
  108. package/schematics/ng-add/helpers/devtools-registration.js.map +1 -0
  109. package/schematics/ng-add/index.d.ts +8 -0
  110. package/schematics/ng-add/index.d.ts.map +1 -0
  111. package/schematics/ng-add/index.js +62 -0
  112. package/schematics/ng-add/index.js.map +1 -0
  113. package/schematics/ng-add/schema.d.ts +11 -0
  114. package/schematics/ng-add/schema.d.ts.map +1 -0
  115. package/schematics/ng-add/schema.js +3 -0
  116. package/schematics/ng-add/schema.js.map +1 -0
  117. package/schematics/ng-add/schema.json +38 -0
  118. package/schematics/package.json +3 -0
  119. package/types/o3r-transloco-rules-engine.d.ts +40 -0
  120. package/types/o3r-transloco-rules-engine.d.ts.map +1 -0
  121. package/types/o3r-transloco.d.ts +804 -0
  122. package/types/o3r-transloco.d.ts.map +1 -0
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
5
+ const architect_1 = require("@angular-devkit/architect");
6
+ const extractors_1 = require("@o3r/extractors");
7
+ const schematics_1 = require("@o3r/schematics");
8
+ const chokidar = require("chokidar");
9
+ const globby_1 = require("globby");
10
+ const localization_generator_1 = require("../helpers/localization-generator");
11
+ const validations_1 = require("./validations");
12
+ /**
13
+ * Builder to extract localization keys from an Otter project
14
+ */
15
+ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderWithMetricsIfInstalled)(async (options, context) => {
16
+ context.reportRunning();
17
+ const localizationExtractor = new localization_generator_1.LocalizationExtractor(path.resolve(context.workspaceRoot, options.tsConfig), context.logger, options);
18
+ const cache = { libs: {}, locs: {} };
19
+ const execute = async (isFirstLoad = true, files) => {
20
+ /** Maximum number of steps */
21
+ const STEP_NUMBER = !isFirstLoad && files ? (files.libs && files.libs.length > 0 ? 1 : 0) + (files.locs && files.locs.length > 0 ? 1 : 0) + 2 : 4;
22
+ let stepValue = 0;
23
+ try {
24
+ // load everything from TSConfig
25
+ if (isFirstLoad) {
26
+ context.reportProgress(STEP_NUMBER, stepValue++, 'Load localization');
27
+ cache.locs = await localizationExtractor.extractLocalizationFromTsConfig(files && files.extraFiles);
28
+ context.reportProgress(STEP_NUMBER, stepValue++, 'Load metadata');
29
+ cache.libs = files && files.libs ? await localizationExtractor.getMetadataFromLibraries(files.libs) : {};
30
+ // Load specific files that have changed
31
+ }
32
+ else {
33
+ if (files && files.locs) {
34
+ context.reportProgress(STEP_NUMBER, stepValue++, 'reload localization');
35
+ const newLocs = await localizationExtractor.getLocalizationMap([...files.locs, ...(files.extraFiles || [])], Object.keys(cache.locs));
36
+ Object.keys(newLocs)
37
+ .forEach((key) => {
38
+ if (cache.locs[key]) {
39
+ newLocs[key].isDependency = cache.locs[key].isDependency;
40
+ }
41
+ });
42
+ cache.locs = {
43
+ ...cache.locs,
44
+ ...newLocs
45
+ };
46
+ }
47
+ if (files && files.libs) {
48
+ context.reportProgress(STEP_NUMBER, stepValue++, 'reload library metadata');
49
+ const newLibs = await localizationExtractor.getMetadataFromFiles(files.libs);
50
+ cache.libs = {
51
+ ...cache.libs,
52
+ ...newLibs
53
+ };
54
+ }
55
+ }
56
+ const metadata = localizationExtractor.generateMetadata(cache.locs, {
57
+ ignoreDuplicateKeys: options.ignoreDuplicateKeys,
58
+ libraryMetadata: cache.libs,
59
+ outputFile: options.outputFile,
60
+ sortKeys: options.sortKeys
61
+ });
62
+ context.reportProgress(STEP_NUMBER, stepValue++, 'Check translations string validation');
63
+ const translationsWithIssue = metadata
64
+ .filter((metadataItem) => !!metadataItem.value
65
+ && validations_1.validators.reduce((isInvalid, validator) => isInvalid || !validator(metadataItem.value), false));
66
+ if (translationsWithIssue.length > 0) {
67
+ throw new schematics_1.O3rCliError(`The following translations are invalid: ${translationsWithIssue.map((translation) => translation.key).join(', ')}`);
68
+ }
69
+ (0, extractors_1.validateJson)(metadata, JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../schemas/localization.metadata.schema.json'), { encoding: 'utf8' })), 'The output of localization metadata is not valid regarding the json schema, please check the details below : \n', options.strictMode);
70
+ context.reportProgress(STEP_NUMBER, STEP_NUMBER, 'Generating metadata');
71
+ // Create output folder if does not exist
72
+ const localizationMetadataFolder = path.dirname(path.resolve(context.workspaceRoot, options.outputFile));
73
+ if (!fs.existsSync(localizationMetadataFolder)) {
74
+ fs.mkdirSync(localizationMetadataFolder, {
75
+ recursive: true
76
+ });
77
+ }
78
+ // Write metadata file
79
+ try {
80
+ await fs.promises.mkdir(path.dirname(path.resolve(context.workspaceRoot, options.outputFile)), { recursive: true });
81
+ }
82
+ catch { }
83
+ await new Promise((resolve, reject) => fs.writeFile(path.resolve(context.workspaceRoot, options.outputFile), options.inline ? JSON.stringify(metadata) : JSON.stringify(metadata, null, 2), (err) => err ? reject(err) : resolve()));
84
+ }
85
+ catch (e) {
86
+ if (e.stack) {
87
+ context.logger.error(e.stack);
88
+ }
89
+ return {
90
+ success: false,
91
+ error: e.message || e.toString()
92
+ };
93
+ }
94
+ context.logger.info(`Localization metadata bundle extracted in ${options.outputFile}.`);
95
+ return {
96
+ success: true
97
+ };
98
+ };
99
+ /**
100
+ * Run a translation generation and report the result
101
+ * @param execution Execution process
102
+ */
103
+ const generateWithReport = async (execution) => {
104
+ const result = await execution;
105
+ if (result.success) {
106
+ context.logger.info('Localization metadata updated');
107
+ }
108
+ else if (result.error) {
109
+ context.logger.error(result.error);
110
+ }
111
+ context.reportStatus('Waiting for changes...');
112
+ return result;
113
+ };
114
+ const initialExtraLocs = options.extraFilePatterns.length > 0 ? (0, globby_1.sync)(options.extraFilePatterns, { cwd: context.currentDirectory }) : [];
115
+ if (options.watch) {
116
+ let currentProcess = generateWithReport(execute(true, { extraFiles: initialExtraLocs, libs: options.libraries }))
117
+ .then(() => {
118
+ currentProcess = undefined;
119
+ });
120
+ await currentProcess;
121
+ /** SCSS file watcher */
122
+ const watcher = chokidar.watch([...Object.keys(cache.locs), ...(options.extraFilePatterns || [])], { ignoreInitial: true });
123
+ const metadataWatcher = chokidar.watch(Object.keys(cache.libs), { ignoreInitial: true });
124
+ const { include, exclude, cwd } = localizationExtractor.getPatternsFromTsConfig();
125
+ const tsWatcher = chokidar.watch(include, { ignoreInitial: true, ignored: exclude, cwd });
126
+ tsWatcher
127
+ .on('add', async (filePath, fileStat) => {
128
+ if (!fileStat || !fileStat.isFile || !/\.ts$/.test(filePath)) {
129
+ return;
130
+ }
131
+ if (currentProcess) {
132
+ await currentProcess;
133
+ }
134
+ context.logger.info('Refreshed full metadata');
135
+ currentProcess = generateWithReport(execute(true, { extraFiles: initialExtraLocs, libs: options.libraries }));
136
+ await currentProcess;
137
+ currentProcess = undefined;
138
+ watcher.add(Object.keys(cache.locs));
139
+ });
140
+ metadataWatcher
141
+ .on('all', async (eventName, filePath) => {
142
+ if (currentProcess) {
143
+ context.logger.debug(`Ignored action ${eventName} on ${filePath}`);
144
+ }
145
+ else {
146
+ context.logger.debug(`Refreshed for action ${eventName} on ${filePath}`);
147
+ currentProcess = generateWithReport(execute(false, { libs: [filePath] }));
148
+ await currentProcess;
149
+ currentProcess = undefined;
150
+ }
151
+ });
152
+ watcher
153
+ .on('all', async (eventName, filePath) => {
154
+ if (currentProcess) {
155
+ context.logger.debug(`Ignored action ${eventName} on ${filePath}`);
156
+ }
157
+ else {
158
+ context.logger.debug(`Refreshed for action ${eventName} on ${filePath}`);
159
+ currentProcess = generateWithReport(execute(false, { locs: [filePath] }));
160
+ await currentProcess;
161
+ currentProcess = undefined;
162
+ }
163
+ });
164
+ context.addTeardown(async () => {
165
+ await watcher.close();
166
+ await metadataWatcher.close();
167
+ await tsWatcher.close();
168
+ });
169
+ // Exit on watcher failure
170
+ return new Promise((_resolve, reject) => {
171
+ // TODO remove cast after https://github.com/paulmillr/chokidar/issues/1392
172
+ watcher.on('error', (err) => reject(err));
173
+ metadataWatcher.on('error', (err) => reject(err));
174
+ tsWatcher.on('error', (err) => reject(err));
175
+ });
176
+ }
177
+ else {
178
+ return execute(true, { extraFiles: initialExtraLocs, libs: options.libraries });
179
+ }
180
+ }));
181
+ //# sourceMappingURL=index.js.map
@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CAAC;gBAC1E,MAAM,cAAc,CAAC;gBACrB,cAAc,GAAG,SAAS,CAAC;YAC7B,CAAC;QACH,CAAC,CAAC,CAAC;QAEL,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE;YAC7B,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,eAAe,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC,CAAC,CAAC;QAEH,0BAA0B;QAC1B,OAAO,IAAI,OAAO,CAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;YACrD,2EAA2E;YAC3E,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAY,CAAC,CAAC,CAAC;YACnD,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAY,CAAC,CAAC,CAAC;YAC3D,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAY,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAClF,CAAC;AACH,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { JsonObject } from '@angular-devkit/core';
2
+ /**
3
+ * Schema for the localization extractor builder
4
+ */
5
+ export interface LocalizationExtractorBuilderSchema extends JsonObject {
6
+ /** Typescript configuration file to build the application */
7
+ tsConfig: string;
8
+ /** If true, extraction process is not interrupted in case of duplicate keys */
9
+ ignoreDuplicateKeys: boolean;
10
+ /** List of libraries imported */
11
+ libraries: string[];
12
+ /** Path to the output file */
13
+ outputFile: string;
14
+ /** Enable watch mode */
15
+ watch: boolean;
16
+ /** Write metadata inline */
17
+ inline: boolean;
18
+ /** Path patterns of files to add to the generated metadata */
19
+ extraFilePatterns: string[];
20
+ /** If true, metadata objects are sorted by keys */
21
+ sortKeys: boolean;
22
+ /** If activated, this option will fail when any property not supported by the CMS is found, it will be ignored if not activated */
23
+ strictMode: boolean;
24
+ }
25
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/localization-extractor/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,WAAW,kCAAmC,SAAQ,UAAU;IAEpE,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IAEjB,+EAA+E;IAC/E,mBAAmB,EAAE,OAAO,CAAC;IAE7B,iCAAiC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IAEpB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;IAEnB,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAC;IAEf,4BAA4B;IAC5B,MAAM,EAAE,OAAO,CAAC;IAEhB,8DAA8D;IAC9D,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAE5B,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAElB,mIAAmI;IACnI,UAAU,EAAE,OAAO,CAAC;CACrB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../builders/localization-extractor/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "type": "object",
4
+ "$id": "LocalizationExtractorBuilderSchema",
5
+ "title": "Localization builder",
6
+ "description": "Localization builder options",
7
+ "properties": {
8
+ "tsConfig": {
9
+ "type": "string",
10
+ "description": "Typescript configuration file to build the application",
11
+ "default": "tsconfig.json"
12
+ },
13
+ "extraFilePatterns": {
14
+ "type": "array",
15
+ "items": {
16
+ "type": "string"
17
+ },
18
+ "description": "Path patterns of files to add to the generated metadata",
19
+ "default": []
20
+ },
21
+ "ignoreDuplicateKeys": {
22
+ "type": "boolean",
23
+ "description": "If true, extraction process is not interrupted in case of duplicate keys",
24
+ "default": false
25
+ },
26
+ "libraries": {
27
+ "type": "array",
28
+ "description": "List of libraries imported",
29
+ "items": {
30
+ "type": "string"
31
+ },
32
+ "default": []
33
+ },
34
+ "outputFile": {
35
+ "type": "string",
36
+ "description": "Path to the output file",
37
+ "default": "localisation.metadata.json"
38
+ },
39
+ "watch": {
40
+ "type": "boolean",
41
+ "description": "Enable watch mode",
42
+ "default": false
43
+ },
44
+ "inline": {
45
+ "type": "boolean",
46
+ "description": "Write metadata inline",
47
+ "default": false
48
+ },
49
+ "sortKeys": {
50
+ "type": "boolean",
51
+ "description": "Sort metadata alphabetically by keys",
52
+ "default": false
53
+ },
54
+ "strictMode": {
55
+ "type": "boolean",
56
+ "description": "If activated, this option will fail when any property not supported by the CMS is found, it will be ignored if not activated",
57
+ "default": false
58
+ }
59
+ },
60
+ "additionalProperties": false,
61
+ "required": []
62
+ }
@@ -0,0 +1,17 @@
1
+ /** Translation Validator */
2
+ export type ValidatorType = (str: string) => boolean;
3
+ /**
4
+ * Check that the opened parentheses are correctly closed
5
+ * @param str translation
6
+ */
7
+ export declare function checkParentheses(str: string): boolean;
8
+ /**
9
+ * Check if the plural instruction always include an "other" case
10
+ * @param str translation
11
+ */
12
+ export declare function checkOtherInPlural(str: string): boolean;
13
+ /**
14
+ * List of validators to apply to the translations
15
+ */
16
+ export declare const validators: ValidatorType[];
17
+ //# sourceMappingURL=validations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../../builders/localization-extractor/validations.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAYrD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,WAmB3C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,WAK7C;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,aAAa,EAGrC,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validators = void 0;
4
+ exports.checkParentheses = checkParentheses;
5
+ exports.checkOtherInPlural = checkOtherInPlural;
6
+ /** Map of opening brackets to their closing counterparts */
7
+ const MAP_BRACKETS = {
8
+ '[': ']',
9
+ '{': '}',
10
+ '(': ')'
11
+ };
12
+ /** List of closing brackets */
13
+ const CLOSURE_BRACKETS = Object.values(MAP_BRACKETS);
14
+ /**
15
+ * Check that the opened parentheses are correctly closed
16
+ * @param str translation
17
+ */
18
+ function checkParentheses(str) {
19
+ const stack = [];
20
+ for (const ch of str) {
21
+ if (MAP_BRACKETS[ch]) {
22
+ stack.push(ch);
23
+ }
24
+ else if (CLOSURE_BRACKETS.includes(ch)) {
25
+ const tail = stack.pop();
26
+ if (!tail) {
27
+ return false;
28
+ }
29
+ const closure = MAP_BRACKETS[tail];
30
+ if (closure !== ch) {
31
+ return false;
32
+ }
33
+ }
34
+ }
35
+ return stack.length === 0;
36
+ }
37
+ /**
38
+ * Check if the plural instruction always include an "other" case
39
+ * @param str translation
40
+ */
41
+ function checkOtherInPlural(str) {
42
+ if (/{[^,]*, *plural *, *.*}/.test(str)) {
43
+ return /{.*other.*}/.test(str);
44
+ }
45
+ return true;
46
+ }
47
+ /**
48
+ * List of validators to apply to the translations
49
+ */
50
+ exports.validators = [
51
+ checkParentheses,
52
+ checkOtherInPlural
53
+ ];
54
+ //# sourceMappingURL=validations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.js","sourceRoot":"","sources":["../../../builders/localization-extractor/validations.ts"],"names":[],"mappings":";;;AAiBA,4CAmBC;AAMD,gDAKC;AA5CD,4DAA4D;AAC5D,MAAM,YAAY,GAAG;IACnB,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,GAAG;CACA,CAAC;AAEX,+BAA+B;AAC/B,MAAM,gBAAgB,GAAa,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAE/D;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,IAAI,YAAY,CAAC,EAA+B,CAAC,EAAE,CAAC;YAClD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;aAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,KAAK,CAAC;YACf,CAAC;YACD,MAAM,OAAO,GAAG,YAAY,CAAC,IAAiC,CAAC,CAAC;YAChE,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;gBACnB,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,IAAI,yBAAyB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACxC,OAAO,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACU,QAAA,UAAU,GAAoB;IACzC,gBAAgB;IAChB,kBAAkB;CACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './localization-metadata-comparison-helper';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../builders/metadata-check/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2CAA2C,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./localization-metadata-comparison-helper"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../builders/metadata-check/helpers/index.ts"],"names":[],"mappings":";;;AAAA,oFAA0D"}
@@ -0,0 +1,14 @@
1
+ import type { MetadataComparator } from '@o3r/extractors';
2
+ import type { JSONLocalization, LocalizationMetadata } from '@o3r/transloco';
3
+ /**
4
+ * Interface describing a localization migration element
5
+ */
6
+ export interface MigrationLocalizationMetadata {
7
+ /** Localization key */
8
+ key: string;
9
+ }
10
+ /**
11
+ * Comparator used to compare one version of localization metadata with another
12
+ */
13
+ export declare const localizationMetadataComparator: Readonly<MetadataComparator<JSONLocalization, MigrationLocalizationMetadata, LocalizationMetadata>>;
14
+ //# sourceMappingURL=localization-metadata-comparison-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization-metadata-comparison-helper.d.ts","sourceRoot":"","sources":["../../../../builders/metadata-check/helpers/localization-metadata-comparison-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AA4BD;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,6BAA6B,EAAE,oBAAoB,CAAC,CAKrI,CAAC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.localizationMetadataComparator = void 0;
4
+ /**
5
+ * Returns an array of localization metadata from a metadata file.
6
+ * @param content Content of a migration metadata file
7
+ */
8
+ const getLocalizationArray = (content) => content;
9
+ /**
10
+ * Returns the localization key identifier
11
+ * @param localization Localization metadata object
12
+ */
13
+ const getLocalizationName = (localization) => localization.key;
14
+ /**
15
+ * Checks if the content type is relevant for localization metadata
16
+ * @param contentType Content type to check
17
+ */
18
+ const isRelevantContentType = (contentType) => contentType === 'LOCALIZATION';
19
+ /**
20
+ * Checks if a localization matches the migration data
21
+ * @param localization Localization metadata object
22
+ * @param migrationData Migration metadata to match against
23
+ */
24
+ const isMigrationLocalizationDataMatch = (localization, migrationData) => getLocalizationName(localization) === migrationData.key;
25
+ /**
26
+ * Comparator used to compare one version of localization metadata with another
27
+ */
28
+ exports.localizationMetadataComparator = {
29
+ getArray: getLocalizationArray,
30
+ getIdentifier: getLocalizationName,
31
+ isRelevantContentType,
32
+ isMigrationDataMatch: isMigrationLocalizationDataMatch
33
+ };
34
+ //# sourceMappingURL=localization-metadata-comparison-helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization-metadata-comparison-helper.js","sourceRoot":"","sources":["../../../../builders/metadata-check/helpers/localization-metadata-comparison-helper.ts"],"names":[],"mappings":";;;AAgBA;;;GAGG;AACH,MAAM,oBAAoB,GAAG,CAAC,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAC;AAExE;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAAC,YAA8B,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC;AAEjF;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,WAAmB,EAAE,EAAE,CAAC,WAAW,KAAK,cAAc,CAAC;AAEtF;;;;GAIG;AACH,MAAM,gCAAgC,GAAG,CAAC,YAA8B,EAAE,aAA4C,EAAE,EAAE,CACxH,mBAAmB,CAAC,YAAY,CAAC,KAAK,aAAa,CAAC,GAAG,CAAC;AAE1D;;GAEG;AACU,QAAA,8BAA8B,GAAwG;IACjJ,QAAQ,EAAE,oBAAoB;IAC9B,aAAa,EAAE,mBAAmB;IAClC,qBAAqB;IACrB,oBAAoB,EAAE,gCAAgC;CAC9C,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { LocalizationMigrationMetadataCheckBuilderSchema } from './schema';
2
+ /**
3
+ * Builder to check for localization metadata breaking changes
4
+ */
5
+ declare const _default: import("@angular-devkit/architect").Builder<LocalizationMigrationMetadataCheckBuilderSchema & import("@angular-devkit/core").JsonObject>;
6
+ export default _default;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../builders/metadata-check/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,+CAA+C,EAChD,MAAM,UAAU,CAAC;AAElB;;GAEG;;AACH,wBAEI"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const architect_1 = require("@angular-devkit/architect");
4
+ const extractors_1 = require("@o3r/extractors");
5
+ const helpers_1 = require("./helpers");
6
+ /**
7
+ * Builder to check for localization metadata breaking changes
8
+ */
9
+ exports.default = (0, architect_1.createBuilder)((0, extractors_1.createBuilderWithMetricsIfInstalled)((options, context) => {
10
+ return (0, extractors_1.checkMetadataBuilder)({ ...options, packageJsonEntry: 'localizationFilePath' }, context, helpers_1.localizationMetadataComparator);
11
+ }));
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../builders/metadata-check/index.ts"],"names":[],"mappings":";;AAAA,yDAGmC;AACnC,gDAGyB;AACzB,uCAEmB;AAKnB;;GAEG;AACH,kBAAe,IAAA,yBAAa,EAAkD,IAAA,gDAAmC,EAAC,CAAC,OAAO,EAAE,OAAO,EAA0B,EAAE;IAC7J,OAAO,IAAA,iCAAoB,EAAC,EAAE,GAAG,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,EAAE,OAAO,EAAE,wCAA8B,CAAC,CAAC;AACjI,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { MigrationMetadataCheckBuilderOptions } from '@o3r/extractors';
2
+ /** Migration metadata check builder schema */
3
+ export interface LocalizationMigrationMetadataCheckBuilderSchema extends MigrationMetadataCheckBuilderOptions {
4
+ }
5
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../builders/metadata-check/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACrC,MAAM,iBAAiB,CAAC;AAEzB,8CAA8C;AAC9C,MAAM,WAAW,+CAAgD,SAAQ,oCAAoC;CAC5G"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../builders/metadata-check/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,46 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "type": "object",
4
+ "$id": "LocalizationMigrationMetadataCheckBuilderSchema",
5
+ "title": "Check localization migration metadata builder",
6
+ "description": "Check localization migration metadata builder",
7
+ "properties": {
8
+ "migrationDataPath": {
9
+ "type": ["string", "array"],
10
+ "items": {
11
+ "type": "string"
12
+ },
13
+ "description": "Glob of the migration files to use."
14
+ },
15
+ "granularity": {
16
+ "type": "string",
17
+ "description": "Granularity of the migration check.",
18
+ "default": "minor",
19
+ "enum": [
20
+ "major",
21
+ "minor"
22
+ ]
23
+ },
24
+ "allowBreakingChanges": {
25
+ "type": "boolean",
26
+ "description": "Are breaking changes allowed.",
27
+ "default": false
28
+ },
29
+ "shouldCheckUnusedMigrationData": {
30
+ "type": "boolean",
31
+ "description": "Whether to throw an error in case of a migration item that is not used during metadata checks",
32
+ "default": false
33
+ },
34
+ "packageManager": {
35
+ "type": "string",
36
+ "description": "Override of the package manager, otherwise it will be determined from the project."
37
+ },
38
+ "metadataPath": {
39
+ "type": "string",
40
+ "description": "Path of the localization metadata file.",
41
+ "default": "./localisation.metadata.json"
42
+ }
43
+ },
44
+ "additionalProperties": false,
45
+ "required": ["migrationDataPath"]
46
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/builders.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/angular/angular-cli/master/packages/angular_devkit/architect/src/builders-schema.json",
3
+ "builders": {
4
+ "i18n": {
5
+ "implementation": "./builders/i18n/",
6
+ "schema": "./builders/i18n/schema.json",
7
+ "description": "Generate the i18n"
8
+ },
9
+ "extractor": {
10
+ "implementation": "./builders/localization-extractor/",
11
+ "schema": "./builders/localization-extractor/schema.json",
12
+ "description": "Extract the localization keys from an Otter project"
13
+ },
14
+ "localization": {
15
+ "implementation": "./builders/localization/",
16
+ "schema": "./builders/localization/schema.json",
17
+ "description": "Generate the localizations"
18
+ },
19
+ "check-localization-migration-metadata": {
20
+ "implementation": "./builders/metadata-check/",
21
+ "schema": "./builders/metadata-check/schema.json",
22
+ "description": "Check for localization metadata breaking changes"
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/angular/angular-cli/main/packages/angular_devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "ng-add": {
5
+ "description": "Add Otter Localization (Transloco) to the project.",
6
+ "factory": "./schematics/ng-add/index#ngAdd",
7
+ "schema": "./schematics/ng-add/schema.json",
8
+ "aliases": ["install", "i"]
9
+ },
10
+ "migration-localization-to-transloco": {
11
+ "description": "Migrate from @o3r/localization (ngx-translate) to @o3r/transloco",
12
+ "factory": "./schematics/migration-localization-to-transloco/index#migrationLocalizationToTransloco",
13
+ "schema": "./schematics/migration-localization-to-transloco/schema.json",
14
+ "aliases": ["migrate-localization", "migrate"]
15
+ },
16
+ "localization-to-component": {
17
+ "description": "[o3r] Add Otter Localization architecture to an existing component",
18
+ "factory": "./schematics/localization-to-component/index#ngAddLocalization",
19
+ "schema": "./schematics/localization-to-component/schema.json",
20
+ "aliases": ["o3r-localization-to-component", "add-localization"]
21
+ },
22
+ "localization-key-to-component": {
23
+ "description": "[o3r] Add Otter Localization key to an existing component",
24
+ "factory": "./schematics/add-localization-key/index#ngAddLocalizationKey",
25
+ "schema": "./schematics/add-localization-key/schema.json",
26
+ "aliases": ["o3r-localization-key-to-component", "add-localization-key"]
27
+ }
28
+ }
29
+ }