Skip to content

Commit e70faa5

Browse files
committed
feat: implement tag support in I18nApi#translate
1 parent e55fc30 commit e70faa5

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • packages/shared-components/src/core/i18n

packages/shared-components/src/core/i18n/I18nApi.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
55
Please see LICENSE files in the repository root for full details.
66
*/
77

8-
import { type I18nApi as II18nApi, type Variables, type Translations } from "@element-hq/element-web-module-api";
8+
import {
9+
type I18nApi as II18nApi,
10+
type Variables,
11+
type Translations,
12+
type Tags,
13+
} from "@element-hq/element-web-module-api";
914

1015
import { humanizeTime } from "../utils/humanize";
1116
import { _t, getLocale, registerTranslations } from "./i18n";
@@ -42,7 +47,10 @@ export class I18nApi implements II18nApi {
4247
* @param key - The key to translate
4348
* @param variables - Optional variables to interpolate into the translation
4449
*/
45-
public translate(this: void, key: TranslationKey, variables?: Variables): string {
50+
public translate(this: void, key: TranslationKey, variables?: Variables): string;
51+
public translate(this: void, key: TranslationKey, variables: Variables | undefined, tags: Tags): React.ReactNode;
52+
public translate(this: void, key: TranslationKey, variables?: Variables, tags?: Tags): string {
53+
if (tags) return _t(key, variables, tags) as string;
4654
return _t(key, variables);
4755
}
4856

0 commit comments

Comments
 (0)