@dws-std/i18n 1.3.1 → 1.4.0
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 +2 -2
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -51,8 +51,8 @@ var defineMessageCatalog = (options) => {
|
|
|
51
51
|
return catalog;
|
|
52
52
|
};
|
|
53
53
|
// src/resolve-message.ts
|
|
54
|
-
var
|
|
55
|
-
var resolveMessage = (target, locale) => target.params ?
|
|
54
|
+
var interpolate = (template, params) => template.replace(/\{\{(\w+)\}\}/g, (_, key) => params[key] ?? `{{${key}}}`);
|
|
55
|
+
var resolveMessage = (target, locale) => target.params ? interpolate(target.translations[locale ?? target.defaultLocale] ?? "", target.params) : target.translations[locale ?? target.defaultLocale] ?? "";
|
|
56
56
|
export {
|
|
57
57
|
resolveMessage,
|
|
58
58
|
entry,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dws-std/i18n",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Type-safe i18n for TypeScript, define localized exception and message catalogs with compile-time validated parameters.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -40,16 +40,16 @@
|
|
|
40
40
|
"test": "bun test --pass-with-no-tests --coverage"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@dws-std/error": "^2.
|
|
43
|
+
"@dws-std/error": "^2.3.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/bun": "^1.3.14",
|
|
47
|
-
"oxfmt": "0.
|
|
48
|
-
"oxlint": "1.
|
|
47
|
+
"oxfmt": "0.55.0",
|
|
48
|
+
"oxlint": "1.70.0",
|
|
49
49
|
"oxlint-tsgolint": "0.23.0",
|
|
50
50
|
"typescript": "^6.0.3"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@dws-std/error": "^2.
|
|
53
|
+
"@dws-std/error": "^2.3.0"
|
|
54
54
|
}
|
|
55
55
|
}
|