Files
keycloak_theme/src/login/i18n/noJsx/GenericI18n_noJsx.ts

65 lines
2.2 KiB
TypeScript
Raw Normal View History

2024-09-21 17:59:16 +02:00
export type GenericI18n_noJsx<MessageKey extends string, LanguageTag extends string> = {
2024-09-22 17:14:03 +02:00
currentLanguage: {
/**
* e.g: "en", "fr", "zh-CN"
*
* The current language
*/
languageTag: LanguageTag;
/**
* e.g: "English", "Français", "中文(简体)"
*
* The current language
*/
label: string;
};
2024-09-21 17:59:16 +02:00
/**
2024-09-22 17:14:03 +02:00
* Array of languages enabled on the realm.
2024-09-21 17:59:16 +02:00
*/
2024-09-22 17:14:03 +02:00
enabledLanguages: {
languageTag: LanguageTag;
label: string;
href: string;
}[];
2024-09-21 17:59:16 +02:00
/**
*
* Examples assuming currentLanguageTag === "en"
* {
* en: {
* "access-denied": "Access denied",
* "impersonateTitleHtml": "<strong>{0}</strong> Impersonate User",
* "bar": "Bar {0}"
* }
* }
*
* msgStr("access-denied") === "Access denied"
* msgStr("not-a-message-key") Throws an error
* msgStr("impersonateTitleHtml", "Foo") === "<strong>Foo</strong> Impersonate User"
* msgStr("${bar}", "<strong>c</strong>") === "Bar &lt;strong&gt;XXX&lt;/strong&gt;"
* The html in the arg is partially escaped for security reasons, it might come from an untrusted source, it's not safe to render it as html.
*/
msgStr: (key: MessageKey, ...args: (string | undefined)[]) => string;
/**
* This is meant to be used when the key argument is variable, something that might have been configured by the user
* in the Keycloak admin for example.
*
* Examples assuming currentLanguageTag === "en"
* {
* en: {
* "access-denied": "Access denied",
* }
* }
*
* advancedMsgStr("${access-denied}") === advancedMsgStr("access-denied") === msgStr("access-denied") === "Access denied"
* advancedMsgStr("${not-a-message-key}") === advancedMsgStr("not-a-message-key") === "not-a-message-key"
*/
advancedMsgStr: (key: string, ...args: (string | undefined)[]) => string;
/**
* Initially the messages are in english (fallback language).
* The translations in the current language are being fetched dynamically.
* This property is true while the translations are being fetched.
*/
isFetchingTranslations: boolean;
};