generated from keycloakify/keycloakify-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(upgrade): upgrade keycloakify to v11
- Loading branch information
1 parent
e0b88ab
commit a470086
Showing
6 changed files
with
83 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,37 @@ | ||
import { ChevronDownIcon } from "@chakra-ui/icons"; | ||
import { Button, Menu, MenuButton, MenuItem, MenuList } from "@chakra-ui/react"; | ||
import { assert } from "keycloakify/tools/assert"; | ||
|
||
import type { I18n } from "../../i18n"; | ||
import type { KcContext } from "../../KcContext"; | ||
|
||
interface LocaleDropdownProps { | ||
locale: KcContext["locale"]; | ||
i18n: I18n; | ||
} | ||
|
||
const LocaleDropdown = (props: LocaleDropdownProps): JSX.Element | null => { | ||
const { locale, i18n } = props; | ||
const { | ||
getChangeLocaleUrl, | ||
labelBySupportedLanguageTag, | ||
currentLanguageTag, | ||
} = i18n; | ||
const { i18n } = props; | ||
const { currentLanguage, enabledLanguages } = i18n; | ||
|
||
return (assert(locale !== undefined), true) && locale.supported.length > 1 ? ( | ||
return ( | ||
<div> | ||
<Menu> | ||
<MenuButton as={Button} rightIcon={<ChevronDownIcon />}> | ||
{labelBySupportedLanguageTag[currentLanguageTag]} | ||
{currentLanguage.label} | ||
</MenuButton> | ||
<MenuList> | ||
{locale.supported.map(({ languageTag }) => ( | ||
{enabledLanguages.map(({ languageTag, label, href }, i) => ( | ||
<MenuItem | ||
id={`language-${i + 1}`} | ||
as="a" | ||
href={getChangeLocaleUrl(languageTag)} | ||
href={href} | ||
key={languageTag} | ||
> | ||
{labelBySupportedLanguageTag[languageTag]} | ||
{label} | ||
</MenuItem> | ||
))} | ||
</MenuList> | ||
</Menu> | ||
</div> | ||
) : null; | ||
); | ||
}; | ||
|
||
export default LocaleDropdown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
import { createUseI18n } from "keycloakify/login"; | ||
import { i18nBuilder } from "keycloakify/login"; | ||
import type { ThemeName } from "src/kc.gen"; | ||
|
||
export const { useI18n, ofTypeI18n } = createUseI18n({ | ||
// NOTE: Here you can override the default i18n messages | ||
// or define new ones that, for example, you would have | ||
// defined in the Keycloak admin UI for UserProfile | ||
// https://user-images.githubusercontent.com/6702424/182050652-522b6fe6-8ee5-49df-aca3-dba2d33f24a5.png | ||
en: { | ||
// Here we overwrite the default english value for the message "doForgotPassword" | ||
// that is "Forgot Password?" see: https://github.com/InseeFrLab/keycloakify/blob/f0ae5ea908e0aa42391af323b6d5e2fd371af851/src/lib/i18n/generated_messages/18.0.1/login/en.ts#L17 | ||
doRegister: "Sign up", | ||
dontYetHaveAnAccount: "Don't yet have an account?", | ||
forgotPassword: "Forgot Password", | ||
rememberMe: "Remember me on this device", | ||
resendConfirmationEmail: "Resend confirmation email", | ||
troubleSigningIn: "Trouble signing in?", | ||
usernameOrEmail: "Email address", | ||
emailNotVerified: | ||
"Your email account has not been verified. Please verify your email before proceeding.", | ||
}, | ||
"zh-CN": { | ||
doRegister: "注册", | ||
dontYetHaveAnAccount: "还没有账户?", | ||
forgotPassword: "忘记密码", | ||
rememberMe: "在这台设备上记住我", | ||
resendConfirmationEmail: "重新发送确认邮件", | ||
troubleSigningIn: "登录遇到问题?", | ||
usernameOrEmail: "电子邮箱地址", | ||
emailNotVerified: | ||
"您的电子邮件帐户尚未经过验证。 请在继续之前验证您的电子邮件。", | ||
}, | ||
}); | ||
const { useI18n, ofTypeI18n } = i18nBuilder | ||
.withThemeName<ThemeName>() | ||
.withCustomTranslations({ | ||
// NOTE: Here you can override the default i18n messages | ||
// or define new ones that, for example, you would have | ||
// defined in the Keycloak admin UI for UserProfile | ||
// https://user-images.githubusercontent.com/6702424/182050652-522b6fe6-8ee5-49df-aca3-dba2d33f24a5.png | ||
en: { | ||
// Here we overwrite the default english value for the message "doForgotPassword" | ||
// that is "Forgot Password?" see: https://github.com/InseeFrLab/keycloakify/blob/f0ae5ea908e0aa42391af323b6d5e2fd371af851/src/lib/i18n/generated_messages/18.0.1/login/en.ts#L17 | ||
doRegister: "Sign up", | ||
dontYetHaveAnAccount: "Don't yet have an account?", | ||
forgotPassword: "Forgot Password", | ||
rememberMe: "Remember me on this device", | ||
resendConfirmationEmail: "Resend confirmation email", | ||
troubleSigningIn: "Trouble signing in?", | ||
usernameOrEmail: "Email address", | ||
emailNotVerified: | ||
"Your email account has not been verified. Please verify your email before proceeding.", | ||
}, | ||
"zh-CN": { | ||
doRegister: "注册", | ||
dontYetHaveAnAccount: "还没有账户?", | ||
forgotPassword: "忘记密码", | ||
rememberMe: "在这台设备上记住我", | ||
resendConfirmationEmail: "重新发送确认邮件", | ||
troubleSigningIn: "登录遇到问题?", | ||
usernameOrEmail: "电子邮箱地址", | ||
emailNotVerified: | ||
"您的电子邮件帐户尚未经过验证。 请在继续之前验证您的电子邮件。", | ||
}, | ||
}) | ||
.build(); | ||
|
||
export type I18n = typeof ofTypeI18n; | ||
type I18n = typeof ofTypeI18n; | ||
|
||
export { type I18n, useI18n }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters