@fluid-topics/ft-i18n 1.2.48 → 1.2.49

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.
@@ -18,6 +18,7 @@ export type FtLitElementWithI18nInterface = {
18
18
  useCustomMessageContexts: boolean;
19
19
  i18n(property: I18nPropertyInit): string;
20
20
  i18n(context: string, key: string, ...args: any[]): string;
21
+ customI18n(value: string): string;
21
22
  addI18nMessages(name: string, defaultMessages?: Record<string, string>): void;
22
23
  addI18nContext(context: I18nMessageContext<any>, defaultMessages?: Record<string, string>): void;
23
24
  onI18nUpdate(context: string): void;
package/build/lit/i18n.js CHANGED
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { FtLitElement, FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
8
8
  import { ftCustomI18nService, ftI18nService } from "@fluid-topics/ft-app-context";
9
9
  import { property } from "lit/decorators.js";
10
+ import { isI18nKey } from "../decorators/i18nAttribute";
10
11
  export const i18nAttributes = Symbol("i18nAttributes");
11
12
  export const i18nListAttributes = Symbol("i18nListAttributes");
12
13
  export const i18nProperties = Symbol("i18nProperties");
@@ -32,6 +33,16 @@ export function withI18n(Class) {
32
33
  const resolvedArgs = (_c = contextOrProperty.args) !== null && _c !== void 0 ? _c : (contextOrProperty.argsProvider ? contextOrProperty.argsProvider(this) : []);
33
34
  return this.getI18nService(contextOrProperty.custom).resolveMessage(contextOrProperty.context, contextOrProperty.key, ...resolvedArgs);
34
35
  }
36
+ customI18n(value) {
37
+ if (isI18nKey(value)) {
38
+ const [context, key] = value.split(".");
39
+ if (!this[i18nManualContexts].has(context)) {
40
+ this.addI18nContext(context, {}, true);
41
+ }
42
+ return this.getI18nService(true).resolveMessage(context, key) || value;
43
+ }
44
+ return value;
45
+ }
35
46
  onI18nUpdate(context) {
36
47
  var _c, _d, _e;
37
48
  (_c = this[i18nAttributes]) === null || _c === void 0 ? void 0 : _c.forEach((init, prop) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-i18n",
3
- "version": "1.2.48",
3
+ "version": "1.2.49",
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.2.48",
23
- "@fluid-topics/ft-wc-utils": "1.2.48",
22
+ "@fluid-topics/ft-app-context": "1.2.49",
23
+ "@fluid-topics/ft-wc-utils": "1.2.49",
24
24
  "lit": "3.1.0"
25
25
  },
26
- "gitHead": "c2298efffb5e12489201c4c46c6b9cd2911adf58"
26
+ "gitHead": "eac6d1d34424e5f5ca7e20068e646caeba2e15a7"
27
27
  }