@adminforth/i18n 1.0.6 → 1.0.7

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/dist/index.js CHANGED
@@ -459,6 +459,9 @@ ${JSON.stringify(strings.reduce((acc, s) => {
459
459
  // in this plugin we will use plugin to fill the database with missing language messages
460
460
  this.tryProcessAndWatch(adminforth);
461
461
  adminforth.tr = (msg, category, lang, params) => __awaiter(this, void 0, void 0, function* () {
462
+ if (!msg) {
463
+ return msg;
464
+ }
462
465
  // console.log('🪲tr', msg, category, lang);
463
466
  // if lang is not supported , throw
464
467
  if (!this.options.supportedLanguages.includes(lang)) {
@@ -475,9 +478,6 @@ ${JSON.stringify(strings.reduce((acc, s) => {
475
478
  const resource = adminforth.resource(resourceConfig.resourceId);
476
479
  const translation = yield resource.get([Filters.EQ(this.enFieldName, msg), Filters.EQ(this.options.categoryFieldName, category)]);
477
480
  if (!translation) {
478
- if (!msg) {
479
- throw Error(`Empty string passed to tr function during translation`);
480
- }
481
481
  yield resource.create({
482
482
  [this.enFieldName]: msg,
483
483
  [this.options.categoryFieldName]: category,
package/index.ts CHANGED
@@ -544,7 +544,10 @@ ${
544
544
  // in this plugin we will use plugin to fill the database with missing language messages
545
545
  this.tryProcessAndWatch(adminforth);
546
546
 
547
- adminforth.tr = async (msg: string, category: string, lang: string, params): Promise<string> => {
547
+ adminforth.tr = async (msg: string | null | undefined, category: string, lang: string, params): Promise<string> => {
548
+ if (!msg) {
549
+ return msg;
550
+ }
548
551
  // console.log('🪲tr', msg, category, lang);
549
552
 
550
553
  // if lang is not supported , throw
@@ -563,10 +566,6 @@ ${
563
566
  const resource = adminforth.resource(resourceConfig.resourceId);
564
567
  const translation = await resource.get([Filters.EQ(this.enFieldName, msg), Filters.EQ(this.options.categoryFieldName, category)]);
565
568
  if (!translation) {
566
-
567
- if (!msg) {
568
- throw Error(`Empty string passed to tr function during translation`);
569
- }
570
569
  await resource.create({
571
570
  [this.enFieldName]: msg,
572
571
  [this.options.categoryFieldName]: category,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",