@fluid-topics/ft-i18n 1.3.28 → 1.3.29
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { I18nAttributeValue } from "../decorators/i18nAttribute";
|
|
2
3
|
export interface I18nAttributeInit<E extends FtLitElement = FtLitElement> {
|
|
3
4
|
custom?: boolean;
|
|
4
5
|
args?: any[];
|
|
@@ -23,6 +24,9 @@ export type RawI18nMessages<T extends I18nMessages> = {
|
|
|
23
24
|
type I18nPropertyProviders<T extends I18nMessages> = {
|
|
24
25
|
[key in keyof T]: Parameters<T[key]> extends [] ? () => I18nPropertyInit : ((argsOrArgsProvider: ((litElement: any) => Parameters<T[key]>) | Parameters<T[key]>) => I18nPropertyInit);
|
|
25
26
|
};
|
|
27
|
+
type I18nAttributeProviders<T extends I18nMessages> = {
|
|
28
|
+
[key in keyof T]: () => I18nAttributeValue;
|
|
29
|
+
};
|
|
26
30
|
export type I18nKeyProviders<T extends I18nMessages> = {
|
|
27
31
|
[key in keyof T]: () => keyof T;
|
|
28
32
|
};
|
|
@@ -36,6 +40,7 @@ export declare class I18nMessageContext<T extends I18nMessages> {
|
|
|
36
40
|
readonly messages: T;
|
|
37
41
|
readonly rawMessages: RawI18nMessages<T>;
|
|
38
42
|
readonly keys: I18nKeyProviders<T>;
|
|
43
|
+
readonly attributes: I18nAttributeProviders<T>;
|
|
39
44
|
get service(): import("@fluid-topics/ft-app-context").FtI18nServiceInternalClass;
|
|
40
45
|
private constructor();
|
|
41
46
|
}
|
|
@@ -26,16 +26,23 @@ export class I18nMessageContext {
|
|
|
26
26
|
args: typeof argsOrArgsProvider === "function" ? undefined : argsOrArgsProvider,
|
|
27
27
|
argsProvider: typeof argsOrArgsProvider === "function" ? argsOrArgsProvider : undefined,
|
|
28
28
|
});
|
|
29
|
-
}
|
|
29
|
+
},
|
|
30
30
|
});
|
|
31
31
|
this.messages = new Proxy({}, {
|
|
32
|
-
get: (target, messageKey) => (...args) => this.service.resolveMessage(this.name, messageKey, ...args)
|
|
32
|
+
get: (target, messageKey) => (...args) => this.service.resolveMessage(this.name, messageKey, ...args),
|
|
33
33
|
});
|
|
34
34
|
this.rawMessages = new Proxy({}, {
|
|
35
|
-
get: (target, messageKey) => this.service.resolveRawMessage(this.name, messageKey)
|
|
35
|
+
get: (target, messageKey) => this.service.resolveRawMessage(this.name, messageKey),
|
|
36
36
|
});
|
|
37
37
|
this.keys = new Proxy({}, {
|
|
38
|
-
get: (target, messageKey) => () => messageKey
|
|
38
|
+
get: (target, messageKey) => () => messageKey,
|
|
39
|
+
});
|
|
40
|
+
this.attributes = new Proxy({}, {
|
|
41
|
+
get: (target, messageKey) => () => ({
|
|
42
|
+
context: this.name,
|
|
43
|
+
key: messageKey,
|
|
44
|
+
message: this.service.resolveRawMessage(this.name, messageKey),
|
|
45
|
+
}),
|
|
39
46
|
});
|
|
40
47
|
}
|
|
41
48
|
}
|
package/build/lit/i18n.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Constructor, FtLitElement, FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
|
|
2
2
|
import { I18nAttributeInit, I18nMessageContext, I18nPropertyInit } from "../generator/I18nMessageContext";
|
|
3
|
+
import { I18nAttributeValue } from "../decorators/i18nAttribute";
|
|
3
4
|
export declare const i18nAttributes: unique symbol;
|
|
4
5
|
export declare const i18nListAttributes: unique symbol;
|
|
5
6
|
export declare const i18nProperties: unique symbol;
|
|
@@ -16,6 +17,7 @@ export type FtLitElementWithI18nInterface = {
|
|
|
16
17
|
[i18nUnsubs]: Map<string, Function>;
|
|
17
18
|
useCustomMessageContexts: boolean;
|
|
18
19
|
i18n(property: I18nPropertyInit | I18nAttributeInit): string;
|
|
20
|
+
awaitI18n(propertyOrValue: I18nPropertyInit | I18nAttributeValue): Promise<string>;
|
|
19
21
|
customI18n(value: string): string;
|
|
20
22
|
/**
|
|
21
23
|
* @deprecated use this.addI18nContext instead
|
package/build/lit/i18n.js
CHANGED
|
@@ -37,6 +37,13 @@ export const withI18n = applyMixinOnce(Symbol("withI18n"), function (Class) {
|
|
|
37
37
|
}
|
|
38
38
|
return message;
|
|
39
39
|
}
|
|
40
|
+
async awaitI18n(propertyOrValue) {
|
|
41
|
+
const { context, custom } = propertyOrValue;
|
|
42
|
+
if (context) {
|
|
43
|
+
await this.getI18nService(custom).prepareContext(context);
|
|
44
|
+
}
|
|
45
|
+
return this.i18n(propertyOrValue);
|
|
46
|
+
}
|
|
40
47
|
customI18n(value, init) {
|
|
41
48
|
if (i18nAttributeConverter.isI18nKey(value)) {
|
|
42
49
|
const [context, key] = value.split(".");
|
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.29",
|
|
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.29",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "1.3.29",
|
|
24
24
|
"lit": "3.1.0"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "52269062e529467d8df60dc7fe7ee1e174c90ada"
|
|
27
27
|
}
|