@fluid-topics/ft-i18n 1.3.16 → 1.3.17
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/build/decorators/I18nAttributeConverter.d.ts +6 -0
- package/build/decorators/I18nAttributeConverter.js +16 -0
- package/build/decorators/i18nAttribute.d.ts +1 -0
- package/build/decorators/i18nAttribute.js +3 -3
- package/build/ft-i18n.light.js +6 -6
- package/build/ft-i18n.min.js +16 -16
- package/build/lit/i18n.d.ts +1 -1
- package/build/lit/i18n.js +15 -11
- package/package.json +4 -4
package/build/lit/i18n.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type FtLitElementWithI18nInterface = {
|
|
|
15
15
|
[i18nContexts]: Map<string, I18nContextDefinition>;
|
|
16
16
|
[i18nUnsubs]: Map<string, Function>;
|
|
17
17
|
useCustomMessageContexts: boolean;
|
|
18
|
-
i18n(property: I18nPropertyInit): string;
|
|
18
|
+
i18n(property: I18nPropertyInit | I18nAttributeInit): string;
|
|
19
19
|
customI18n(value: string): string;
|
|
20
20
|
/**
|
|
21
21
|
* @deprecated use this.addI18nContext instead
|
package/build/lit/i18n.js
CHANGED
|
@@ -25,17 +25,21 @@ export function withI18n(Class) {
|
|
|
25
25
|
getI18nService(custom) {
|
|
26
26
|
return (custom !== null && custom !== void 0 ? custom : this.useCustomMessageContexts) ? ftCustomI18nService : ftI18nService;
|
|
27
27
|
}
|
|
28
|
-
i18n(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
i18n(propertyOrValue) {
|
|
29
|
+
const { context, key, message } = propertyOrValue;
|
|
30
|
+
const { custom, args, argsProvider } = propertyOrValue;
|
|
31
|
+
if (context && key) {
|
|
32
|
+
if (!this.hasI18nContext(context)) {
|
|
33
|
+
this.addI18nContext(context, undefined, custom);
|
|
34
|
+
}
|
|
35
|
+
const resolvedArgs = args !== null && args !== void 0 ? args : (argsProvider ? argsProvider(this) : []);
|
|
36
|
+
return this.getI18nService(custom).resolveMessage(context, key, ...resolvedArgs);
|
|
32
37
|
}
|
|
33
|
-
|
|
34
|
-
return this.getI18nService(property.custom).resolveMessage(property.context, property.key, ...resolvedArgs);
|
|
38
|
+
return message;
|
|
35
39
|
}
|
|
36
40
|
customI18n(value, init) {
|
|
37
41
|
if (isI18nKey(value)) {
|
|
38
|
-
|
|
42
|
+
const [context, key] = value.split(".");
|
|
39
43
|
return this.i18n({ custom: true, context, key, ...init }) || value;
|
|
40
44
|
}
|
|
41
45
|
return value;
|
|
@@ -60,12 +64,12 @@ export function withI18n(Class) {
|
|
|
60
64
|
const self = this;
|
|
61
65
|
const update = (init, prop, value) => {
|
|
62
66
|
if ((value === null || value === void 0 ? void 0 : value.context) && value.key && condition(init, prop, value)) {
|
|
63
|
-
return { ...value, message: this.i18n({ context: value.context, key: value.key, ...init }) };
|
|
67
|
+
return { ...value, message: this.i18n({ context: value.context, key: value.key, custom: value.custom, ...init }) };
|
|
64
68
|
}
|
|
65
69
|
return value;
|
|
66
70
|
};
|
|
67
71
|
(_c = this[i18nAttributes]) === null || _c === void 0 ? void 0 : _c.forEach((init, prop) => self[prop] = update(init, prop, self[prop]));
|
|
68
|
-
(_d = this[i18nListAttributes]) === null || _d === void 0 ? void 0 : _d.forEach((init, prop) => { var _c; return self[prop] = (_c = self[prop]) === null || _c === void 0 ? void 0 : _c.map(value => update(init, prop, value)); });
|
|
72
|
+
(_d = this[i18nListAttributes]) === null || _d === void 0 ? void 0 : _d.forEach((init, prop) => { var _c; return self[prop] = (_c = self[prop]) === null || _c === void 0 ? void 0 : _c.map((value) => update(init, prop, value)); });
|
|
69
73
|
}
|
|
70
74
|
updateI18nProperties(condition) {
|
|
71
75
|
var _c;
|
|
@@ -83,7 +87,7 @@ export function withI18n(Class) {
|
|
|
83
87
|
this.addI18nContext(context, defaultMessages, isCustomContext);
|
|
84
88
|
}
|
|
85
89
|
addI18nContext(context, defaultMessages, isCustomContext) {
|
|
86
|
-
|
|
90
|
+
const contextName = (typeof context === "string" ? context : context.name).toLowerCase();
|
|
87
91
|
isCustomContext = typeof context === "string" ? isCustomContext : context.custom;
|
|
88
92
|
this[i18nContexts].set(contextName, { isCustomContext });
|
|
89
93
|
if (!this[i18nUnsubs].has(contextName)) {
|
|
@@ -100,7 +104,7 @@ export function withI18n(Class) {
|
|
|
100
104
|
}
|
|
101
105
|
disconnectedCallback() {
|
|
102
106
|
super.disconnectedCallback();
|
|
103
|
-
this[i18nUnsubs].forEach(unsub => unsub());
|
|
107
|
+
this[i18nUnsubs].forEach((unsub) => unsub());
|
|
104
108
|
this[i18nUnsubs].clear();
|
|
105
109
|
}
|
|
106
110
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-i18n",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17",
|
|
4
4
|
"description": "Integrated component that displays internationalized label from a Fluid Topics portal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "1.3.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "1.3.
|
|
22
|
+
"@fluid-topics/ft-app-context": "1.3.17",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "1.3.17",
|
|
24
24
|
"lit": "3.1.0"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "ca55c7b44d386d960ceb68323361ce0ab3aefaa8"
|
|
27
27
|
}
|