@adminforth/i18n 1.0.12 → 1.0.13
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.md +8 -0
- package/dist/index.js +10 -2
- package/index.ts +14 -2
- package/package.json +1 -1
package/Changelog.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [1.0.13]
|
|
12
|
+
|
|
13
|
+
- Deduplicate frontend strings before creating translations
|
|
14
|
+
|
|
15
|
+
|
|
8
16
|
## [1.0.12]
|
|
9
17
|
|
|
10
18
|
### Fixed
|
package/dist/index.js
CHANGED
|
@@ -444,7 +444,13 @@ ${JSON.stringify(strings.reduce((acc, s) => {
|
|
|
444
444
|
return;
|
|
445
445
|
}
|
|
446
446
|
// loop over missingKeys[i].path and add them to database if not exists
|
|
447
|
-
|
|
447
|
+
const missingKeysDeduplicated = messages.missingKeys.reduce((acc, missingKey) => {
|
|
448
|
+
if (!acc.find((a) => a.path === missingKey.path)) {
|
|
449
|
+
acc.push(missingKey);
|
|
450
|
+
}
|
|
451
|
+
return acc;
|
|
452
|
+
}, []);
|
|
453
|
+
yield Promise.all(missingKeysDeduplicated.map((missingKey) => __awaiter(this, void 0, void 0, function* () {
|
|
448
454
|
const key = missingKey.path;
|
|
449
455
|
const file = missingKey.file;
|
|
450
456
|
const category = 'frontend';
|
|
@@ -472,15 +478,17 @@ ${JSON.stringify(strings.reduce((acc, s) => {
|
|
|
472
478
|
const serveDir = adminforth.codeInjector.getServeDir();
|
|
473
479
|
// messages file is in i18n-messages.json
|
|
474
480
|
const messagesFile = path.join(serveDir, 'i18n-messages.json');
|
|
475
|
-
console.log('
|
|
481
|
+
process.env.HEAVY_DEBUG && console.log('🪲🔔messagesFile read started', messagesFile);
|
|
476
482
|
this.processExtractedMessages(adminforth, messagesFile);
|
|
477
483
|
// we use watcher because file can't be yet created when we start - bundleNow can be done in build time or can be done now
|
|
478
484
|
// that is why we make attempt to process it now and then watch for changes
|
|
479
485
|
const w = chokidar.watch(messagesFile, { persistent: true });
|
|
480
486
|
w.on('change', () => {
|
|
487
|
+
process.env.HEAVY_DEBUG && console.log('🪲🔔messagesFile change', messagesFile);
|
|
481
488
|
this.processExtractedMessages(adminforth, messagesFile);
|
|
482
489
|
});
|
|
483
490
|
w.on('add', () => {
|
|
491
|
+
process.env.HEAVY_DEBUG && console.log('🪲🔔messagesFile add', messagesFile);
|
|
484
492
|
this.processExtractedMessages(adminforth, messagesFile);
|
|
485
493
|
});
|
|
486
494
|
});
|
package/index.ts
CHANGED
|
@@ -535,7 +535,15 @@ ${
|
|
|
535
535
|
return;
|
|
536
536
|
}
|
|
537
537
|
// loop over missingKeys[i].path and add them to database if not exists
|
|
538
|
-
|
|
538
|
+
|
|
539
|
+
const missingKeysDeduplicated = messages.missingKeys.reduce((acc: any[], missingKey: any) => {
|
|
540
|
+
if (!acc.find((a) => a.path === missingKey.path)) {
|
|
541
|
+
acc.push(missingKey);
|
|
542
|
+
}
|
|
543
|
+
return acc;
|
|
544
|
+
}, []);
|
|
545
|
+
|
|
546
|
+
await Promise.all(missingKeysDeduplicated.map(async (missingKey: any) => {
|
|
539
547
|
const key = missingKey.path;
|
|
540
548
|
const file = missingKey.file;
|
|
541
549
|
const category = 'frontend';
|
|
@@ -567,15 +575,19 @@ ${
|
|
|
567
575
|
const serveDir = adminforth.codeInjector.getServeDir();
|
|
568
576
|
// messages file is in i18n-messages.json
|
|
569
577
|
const messagesFile = path.join(serveDir, 'i18n-messages.json');
|
|
570
|
-
console.log('
|
|
578
|
+
process.env.HEAVY_DEBUG && console.log('🪲🔔messagesFile read started', messagesFile);
|
|
571
579
|
this.processExtractedMessages(adminforth, messagesFile);
|
|
572
580
|
// we use watcher because file can't be yet created when we start - bundleNow can be done in build time or can be done now
|
|
573
581
|
// that is why we make attempt to process it now and then watch for changes
|
|
574
582
|
const w = chokidar.watch(messagesFile, { persistent: true });
|
|
575
583
|
w.on('change', () => {
|
|
584
|
+
process.env.HEAVY_DEBUG && console.log('🪲🔔messagesFile change', messagesFile);
|
|
585
|
+
|
|
576
586
|
this.processExtractedMessages(adminforth, messagesFile);
|
|
577
587
|
});
|
|
578
588
|
w.on('add', () => {
|
|
589
|
+
process.env.HEAVY_DEBUG && console.log('🪲🔔messagesFile add', messagesFile);
|
|
590
|
+
|
|
579
591
|
this.processExtractedMessages(adminforth, messagesFile);
|
|
580
592
|
});
|
|
581
593
|
|