@midwayjs/i18n 3.20.16 → 3.20.19

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.
@@ -21,5 +21,6 @@ exports.i18n = {
21
21
  },
22
22
  },
23
23
  localsField: 'i18n',
24
+ missingKeyHandler: message => message,
24
25
  };
25
26
  //# sourceMappingURL=config.default.js.map
@@ -79,6 +79,10 @@ let MidwayI18nServiceSingleton = class MidwayI18nServiceSingleton {
79
79
  msg = this.getLocaleMappingText(this.defaultLocale, message, group, args);
80
80
  }
81
81
  }
82
+ // If still no message found, use missingKeyHandler
83
+ if (!msg && this.i18nConfig.missingKeyHandler) {
84
+ msg = this.i18nConfig.missingKeyHandler(message, options);
85
+ }
82
86
  return msg;
83
87
  }
84
88
  /**
@@ -18,6 +18,7 @@ export interface I18nOptions {
18
18
  writeCookie: boolean;
19
19
  resolver: RequestResolver | false;
20
20
  localsField: string;
21
+ missingKeyHandler?: (message: string, options?: TranslateOptions) => string;
21
22
  }
22
23
  export declare const I18N_ATTR_KEY = "i18n:locale";
23
24
  //# sourceMappingURL=interface.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midwayjs/i18n",
3
3
  "description": "midway i18n component",
4
- "version": "3.20.16",
4
+ "version": "3.20.19",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "files": [
@@ -13,10 +13,10 @@
13
13
  "picomatch": "2.3.1"
14
14
  },
15
15
  "devDependencies": {
16
- "@midwayjs/core": "^3.20.11",
17
- "@midwayjs/express": "^3.20.12",
18
- "@midwayjs/koa": "^3.20.16",
19
- "@midwayjs/mock": "^3.20.11"
16
+ "@midwayjs/core": "^3.20.19",
17
+ "@midwayjs/express": "^3.20.19",
18
+ "@midwayjs/koa": "^3.20.19",
19
+ "@midwayjs/mock": "^3.20.19"
20
20
  },
21
21
  "keywords": [
22
22
  "midway",
@@ -38,5 +38,5 @@
38
38
  "type": "git",
39
39
  "url": "https://github.com/midwayjs/midway.git"
40
40
  },
41
- "gitHead": "54b937490d350566074f2d65b6bef8ab38a0892e"
41
+ "gitHead": "a163376426d8bec46fd73674715447556de88c5c"
42
42
  }