@adminforth/i18n 1.0.13 → 1.0.14
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 +5 -0
- package/dist/index.js +7 -1
- package/index.ts +9 -2
- package/package.json +2 -1
package/Changelog.md
CHANGED
|
@@ -6,7 +6,12 @@ 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
8
|
|
|
9
|
+
## [1.0.14]
|
|
9
10
|
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Add `ignoreInitial` for watch to prevent initial messages loading
|
|
14
|
+
- Add locking mechanism to prevent initial messages loading call in parallel (just in case)
|
|
10
15
|
|
|
11
16
|
## [1.0.13]
|
|
12
17
|
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,8 @@ import iso6391 from 'iso-639-1';
|
|
|
12
12
|
import path from 'path';
|
|
13
13
|
import fs from 'fs-extra';
|
|
14
14
|
import chokidar from 'chokidar';
|
|
15
|
+
import { AsyncQueue } from '@sapphire/async-queue';
|
|
16
|
+
const processFrontendMessagesQueue = new AsyncQueue();
|
|
15
17
|
const SLAVIC_PLURAL_EXAMPLES = {
|
|
16
18
|
uk: 'яблук | Яблуко | Яблука | Яблук', // zero | singular | 2-4 | 5+
|
|
17
19
|
bg: 'ябълки | ябълка | ябълки | ябълки', // zero | singular | 2-4 | 5+
|
|
@@ -433,6 +435,7 @@ ${JSON.stringify(strings.reduce((acc, s) => {
|
|
|
433
435
|
}
|
|
434
436
|
processExtractedMessages(adminforth, filePath) {
|
|
435
437
|
return __awaiter(this, void 0, void 0, function* () {
|
|
438
|
+
yield processFrontendMessagesQueue.wait();
|
|
436
439
|
// messages file is in i18n-messages.json
|
|
437
440
|
let messages;
|
|
438
441
|
try {
|
|
@@ -482,7 +485,10 @@ ${JSON.stringify(strings.reduce((acc, s) => {
|
|
|
482
485
|
this.processExtractedMessages(adminforth, messagesFile);
|
|
483
486
|
// 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
|
|
484
487
|
// that is why we make attempt to process it now and then watch for changes
|
|
485
|
-
const w = chokidar.watch(messagesFile, {
|
|
488
|
+
const w = chokidar.watch(messagesFile, {
|
|
489
|
+
persistent: true,
|
|
490
|
+
ignoreInitial: true, // don't trigger 'add' event for existing file on start
|
|
491
|
+
});
|
|
486
492
|
w.on('change', () => {
|
|
487
493
|
process.env.HEAVY_DEBUG && console.log('🪲🔔messagesFile change', messagesFile);
|
|
488
494
|
this.processExtractedMessages(adminforth, messagesFile);
|
package/index.ts
CHANGED
|
@@ -5,6 +5,9 @@ import iso6391, { LanguageCode } from 'iso-639-1';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import fs from 'fs-extra';
|
|
7
7
|
import chokidar from 'chokidar';
|
|
8
|
+
import { AsyncQueue } from '@sapphire/async-queue';
|
|
9
|
+
|
|
10
|
+
const processFrontendMessagesQueue = new AsyncQueue();
|
|
8
11
|
|
|
9
12
|
const SLAVIC_PLURAL_EXAMPLES = {
|
|
10
13
|
uk: 'яблук | Яблуко | Яблука | Яблук', // zero | singular | 2-4 | 5+
|
|
@@ -524,6 +527,7 @@ ${
|
|
|
524
527
|
}
|
|
525
528
|
|
|
526
529
|
async processExtractedMessages(adminforth: IAdminForth, filePath: string) {
|
|
530
|
+
await processFrontendMessagesQueue.wait();
|
|
527
531
|
// messages file is in i18n-messages.json
|
|
528
532
|
let messages;
|
|
529
533
|
try {
|
|
@@ -535,7 +539,7 @@ ${
|
|
|
535
539
|
return;
|
|
536
540
|
}
|
|
537
541
|
// loop over missingKeys[i].path and add them to database if not exists
|
|
538
|
-
|
|
542
|
+
|
|
539
543
|
const missingKeysDeduplicated = messages.missingKeys.reduce((acc: any[], missingKey: any) => {
|
|
540
544
|
if (!acc.find((a) => a.path === missingKey.path)) {
|
|
541
545
|
acc.push(missingKey);
|
|
@@ -579,7 +583,10 @@ ${
|
|
|
579
583
|
this.processExtractedMessages(adminforth, messagesFile);
|
|
580
584
|
// 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
|
|
581
585
|
// that is why we make attempt to process it now and then watch for changes
|
|
582
|
-
const w = chokidar.watch(messagesFile, {
|
|
586
|
+
const w = chokidar.watch(messagesFile, {
|
|
587
|
+
persistent: true,
|
|
588
|
+
ignoreInitial: true, // don't trigger 'add' event for existing file on start
|
|
589
|
+
});
|
|
583
590
|
w.on('change', () => {
|
|
584
591
|
process.env.HEAVY_DEBUG && console.log('🪲🔔messagesFile change', messagesFile);
|
|
585
592
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/i18n",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"description": "",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@aws-sdk/client-ses": "^3.654.0",
|
|
18
|
+
"@sapphire/async-queue": "^1.5.5",
|
|
18
19
|
"chokidar": "^4.0.1",
|
|
19
20
|
"iso-639-1": "^3.1.3"
|
|
20
21
|
},
|