@adminforth/i18n 1.0.18-next.3 โ†’ 1.0.18-next.5

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 (3) hide show
  1. package/dist/index.js +10 -2
  2. package/index.ts +16 -5
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -422,20 +422,25 @@ ${JSON.stringify(strings.reduce((acc, s) => {
422
422
  yield Promise.all(Object.entries(needToTranslateByLang).map((_b) => __awaiter(this, [_b], void 0, function* ([lang, strings]) {
423
423
  // first translate without plurals
424
424
  const stringsWithoutPlurals = strings.filter(s => !s.en_string.includes('|'));
425
+ process.env.HEAVY_DEBUG && console.log(`๐Ÿ”— ${lang} noplurals started ${stringsWithoutPlurals.length}`);
425
426
  const noPluralKeys = yield translateToLang(lang, stringsWithoutPlurals, false);
427
+ process.env.HEAVY_DEBUG && console.log(`๐Ÿ”— ${lang} noplurals finished`);
426
428
  const stringsWithPlurals = strings.filter(s => s.en_string.includes('|'));
429
+ process.env.HEAVY_DEBUG && console.log(`๐Ÿ”— ${lang} plurals started ${stringsWithPlurals.length}`);
427
430
  const pluralKeys = yield translateToLang(lang, stringsWithPlurals, true);
431
+ process.env.HEAVY_DEBUG && console.log(`๐Ÿ”— ${lang} plurals finished`);
428
432
  totalTranslated = totalTranslated.concat(noPluralKeys, pluralKeys);
429
433
  })));
434
+ process.env.HEAVY_DEBUG && console.log('updateStrings were formed', totalTranslated);
430
435
  yield Promise.all(Object.entries(updateStrings).map((_c) => __awaiter(this, [_c], void 0, function* ([_, { updates, strId }]) {
431
436
  // because this will translate all languages, we can set completedLangs to all languages
432
437
  const futureCompletedFieldValue = this.fullCompleatedFieldValue;
433
438
  yield this.adminforth.resource(this.resourceConfig.resourceId).update(strId, Object.assign(Object.assign({}, updates), { [this.options.completedFieldName]: futureCompletedFieldValue }));
434
439
  })));
435
440
  for (const lang of langsInvolved) {
436
- this.cache.clear(`${this.resourceConfig.resourceId}:frontend:${lang}`);
441
+ yield this.cache.clear(`${this.resourceConfig.resourceId}:frontend:${lang}`);
437
442
  for (const [enStr, { category }] of Object.entries(updateStrings)) {
438
- this.cache.clear(`${this.resourceConfig.resourceId}:${category}:${lang}:${enStr}`);
443
+ yield this.cache.clear(`${this.resourceConfig.resourceId}:${category}:${lang}:${enStr}`);
439
444
  }
440
445
  }
441
446
  return new Set(totalTranslated).size;
@@ -510,6 +515,9 @@ ${JSON.stringify(strings.reduce((acc, s) => {
510
515
  validateConfigAfterDiscover(adminforth, resourceConfig) {
511
516
  // optional method where you can safely check field types after database discovery was performed
512
517
  // ensure each trFieldName (apart from enFieldName) is nullable column of type string
518
+ if (this.options.completeAdapter) {
519
+ this.options.completeAdapter.validate();
520
+ }
513
521
  for (const lang of this.options.supportedLanguages) {
514
522
  if (lang === 'en') {
515
523
  continue;
package/index.ts CHANGED
@@ -503,12 +503,21 @@ ${
503
503
  await Promise.all(Object.entries(needToTranslateByLang).map(async ([lang, strings]: [LanguageCode, { en_string: string, category: string }[]]) => {
504
504
  // first translate without plurals
505
505
  const stringsWithoutPlurals = strings.filter(s => !s.en_string.includes('|'));
506
+ process.env.HEAVY_DEBUG && console.log(`๐Ÿ”— ${lang} noplurals started ${stringsWithoutPlurals.length}`);
506
507
  const noPluralKeys = await translateToLang(lang, stringsWithoutPlurals, false);
508
+ process.env.HEAVY_DEBUG && console.log(`๐Ÿ”— ${lang} noplurals finished`);
509
+
507
510
 
508
511
  const stringsWithPlurals = strings.filter(s => s.en_string.includes('|'));
512
+
513
+ process.env.HEAVY_DEBUG && console.log(`๐Ÿ”— ${lang} plurals started ${stringsWithPlurals.length}`);
509
514
  const pluralKeys = await translateToLang(lang, stringsWithPlurals, true);
515
+ process.env.HEAVY_DEBUG && console.log(`๐Ÿ”— ${lang} plurals finished`);
516
+
510
517
  totalTranslated = totalTranslated.concat(noPluralKeys, pluralKeys);
511
- }));
518
+ }));
519
+
520
+ process.env.HEAVY_DEBUG && console.log('updateStrings were formed', totalTranslated);
512
521
 
513
522
  await Promise.all(
514
523
  Object.entries(updateStrings).map(
@@ -525,9 +534,9 @@ ${
525
534
  );
526
535
 
527
536
  for (const lang of langsInvolved) {
528
- this.cache.clear(`${this.resourceConfig.resourceId}:frontend:${lang}`);
537
+ await this.cache.clear(`${this.resourceConfig.resourceId}:frontend:${lang}`);
529
538
  for (const [enStr, { category }] of Object.entries(updateStrings)) {
530
- this.cache.clear(`${this.resourceConfig.resourceId}:${category}:${lang}:${enStr}`);
539
+ await this.cache.clear(`${this.resourceConfig.resourceId}:${category}:${lang}:${enStr}`);
531
540
  }
532
541
  }
533
542
 
@@ -598,12 +607,10 @@ ${
598
607
  });
599
608
  w.on('change', () => {
600
609
  process.env.HEAVY_DEBUG && console.log('๐Ÿชฒ๐Ÿ””messagesFile change', messagesFile);
601
-
602
610
  this.processExtractedMessages(adminforth, messagesFile);
603
611
  });
604
612
  w.on('add', () => {
605
613
  process.env.HEAVY_DEBUG && console.log('๐Ÿชฒ๐Ÿ””messagesFile add', messagesFile);
606
-
607
614
  this.processExtractedMessages(adminforth, messagesFile);
608
615
  });
609
616
 
@@ -612,6 +619,10 @@ ${
612
619
  validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
613
620
  // optional method where you can safely check field types after database discovery was performed
614
621
  // ensure each trFieldName (apart from enFieldName) is nullable column of type string
622
+ if (this.options.completeAdapter) {
623
+ this.options.completeAdapter.validate();
624
+ }
625
+
615
626
  for (const lang of this.options.supportedLanguages) {
616
627
  if (lang === 'en') {
617
628
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "1.0.18-next.3",
3
+ "version": "1.0.18-next.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",