From bab7a607db35cd0de2f79a82fc4f7a475b110cfe Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Mon, 24 Oct 2022 12:26:11 +0800 Subject: [PATCH] refactor: update language kit (#2232) --- packages/cli/package.json | 2 +- packages/console/package.json | 4 +- .../Connectors/components/Guide/index.tsx | 5 +- .../UserDetails/components/UserConnectors.tsx | 2 +- packages/core/package.json | 6 +- packages/core/src/__mocks__/connector.ts | 4 +- packages/demo-app/package.json | 2 +- packages/phrases-ui/package.json | 4 +- packages/phrases-ui/src/index.ts | 6 +- .../src/locales/{ko-kr.ts => ko.ts} | 4 +- packages/phrases/package.json | 4 +- packages/phrases/src/index.ts | 6 +- .../src/locales/{ko-kr => ko}/errors.ts | 0 .../src/locales/{ko-kr => ko}/index.ts | 4 +- .../admin-console/api-resource-details.ts | 0 .../admin-console/api-resources.ts | 0 .../admin-console/application-details.ts | 0 .../translation/admin-console/applications.ts | 0 .../admin-console/connector-details.ts | 0 .../translation/admin-console/connectors.ts | 0 .../translation/admin-console/contact.ts | 0 .../translation/admin-console/dashboard.ts | 0 .../translation/admin-console/errors.ts | 0 .../translation/admin-console/general.ts | 0 .../translation/admin-console/get-started.ts | 0 .../translation/admin-console/index.ts | 0 .../translation/admin-console/log-details.ts | 0 .../translation/admin-console/logs.ts | 0 .../admin-console/session-expired.ts | 0 .../translation/admin-console/settings.ts | 0 .../translation/admin-console/sign-in-exp.ts | 0 .../translation/admin-console/tab-sections.ts | 0 .../translation/admin-console/tabs.ts | 0 .../translation/admin-console/user-details.ts | 0 .../translation/admin-console/users.ts | 0 .../translation/admin-console/welcome.ts | 0 .../{ko-kr => ko}/translation/demo-app.ts | 0 .../{ko-kr => ko}/translation/index.ts | 0 packages/schemas/package.json | 6 +- packages/ui/package.json | 1 + packages/ui/src/__mocks__/logto.tsx | 24 ++-- .../SocialSignInDropdown/index.tsx | 5 +- pnpm-lock.yaml | 109 +++++++++--------- 43 files changed, 102 insertions(+), 96 deletions(-) rename packages/phrases-ui/src/locales/{ko-kr.ts => ko.ts} (98%) rename packages/phrases/src/locales/{ko-kr => ko}/errors.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/index.ts (70%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/api-resource-details.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/api-resources.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/application-details.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/applications.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/connector-details.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/connectors.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/contact.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/dashboard.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/errors.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/general.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/get-started.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/index.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/log-details.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/logs.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/session-expired.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/settings.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/sign-in-exp.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/tab-sections.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/tabs.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/user-details.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/users.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/admin-console/welcome.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/demo-app.ts (100%) rename packages/phrases/src/locales/{ko-kr => ko}/translation/index.ts (100%) diff --git a/packages/cli/package.json b/packages/cli/package.json index 475bc6234..e96ac48b6 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -60,7 +60,7 @@ "slonik-sql-tag-raw": "^1.1.4", "tar": "^6.1.11", "yargs": "^17.6.0", - "zod": "^3.18.0" + "zod": "^3.19.1" }, "devDependencies": { "@silverhand/eslint-config": "1.3.0", diff --git a/packages/console/package.json b/packages/console/package.json index ee49df453..a05b32ff9 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -19,7 +19,7 @@ "devDependencies": { "@fontsource/roboto-mono": "^4.5.7", "@logto/core-kit": "1.0.0-beta.19", - "@logto/language-kit": "1.0.0-beta.19", + "@logto/language-kit": "1.0.0-beta.20", "@logto/phrases": "workspace:^", "@logto/phrases-ui": "workspace:^", "@logto/react": "1.0.0-beta.10", @@ -82,7 +82,7 @@ "stylelint": "^14.9.1", "swr": "^1.3.0", "typescript": "^4.7.4", - "zod": "^3.18.0" + "zod": "^3.19.1" }, "alias": { "@/*": "./src/$1", diff --git a/packages/console/src/pages/Connectors/components/Guide/index.tsx b/packages/console/src/pages/Connectors/components/Guide/index.tsx index 3ee3b58a2..07bc04aba 100644 --- a/packages/console/src/pages/Connectors/components/Guide/index.tsx +++ b/packages/console/src/pages/Connectors/components/Guide/index.tsx @@ -1,4 +1,4 @@ -import { getDefaultLanguage } from '@logto/core-kit'; +import { isLanguageTag } from '@logto/language-kit'; import type { ConnectorResponse } from '@logto/schemas'; import { ConnectorType } from '@logto/schemas'; import { conditional } from '@silverhand/essentials'; @@ -32,7 +32,8 @@ const Guide = ({ connector, onClose }: Props) => { const { updateSettings } = useSettings(); const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { id: connectorId, type: connectorType, name, configTemplate, readme } = connector; - const connectorName = name[getDefaultLanguage(i18next.language)]; + const { language } = i18next; + const connectorName = conditional(isLanguageTag(language) && name[language]) ?? name.en; const isSocialConnector = connectorType !== ConnectorType.Sms && connectorType !== ConnectorType.Email; const methods = useForm({ reValidateMode: 'onBlur' }); diff --git a/packages/console/src/pages/UserDetails/components/UserConnectors.tsx b/packages/console/src/pages/UserDetails/components/UserConnectors.tsx index 54d34b2d4..82b0b05b2 100644 --- a/packages/console/src/pages/UserDetails/components/UserConnectors.tsx +++ b/packages/console/src/pages/UserDetails/components/UserConnectors.tsx @@ -59,7 +59,7 @@ const UserConnectors = ({ userId, connectors, onDelete }: Props) => { 'zh-CN': '未知连接器', en: 'Unknown Connector', 'tr-TR': 'Bilinmeyen connector.', - 'ko-KR': '알수없는 연동', + ko: '알수없는 연동', }, target: key, userId: connectors[key]?.userId, diff --git a/packages/core/package.json b/packages/core/package.json index 1e51e50db..40a987b77 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -20,9 +20,9 @@ }, "dependencies": { "@logto/cli": "workspace:^", - "@logto/connector-kit": "^1.0.0-beta.18", + "@logto/connector-kit": "1.0.0-beta.20", "@logto/core-kit": "^1.0.0-beta.18", - "@logto/language-kit": "1.0.0-beta.19", + "@logto/language-kit": "1.0.0-beta.20", "@logto/phrases": "workspace:^", "@logto/phrases-ui": "workspace:^", "@logto/schemas": "workspace:^", @@ -64,7 +64,7 @@ "slonik-sql-tag-raw": "^1.1.4", "snake-case": "^3.0.4", "snakecase-keys": "^5.1.0", - "zod": "^3.18.0" + "zod": "^3.19.1" }, "devDependencies": { "@shopify/jest-koa-mocks": "^5.0.0", diff --git a/packages/core/src/__mocks__/connector.ts b/packages/core/src/__mocks__/connector.ts index 4d3e4bbab..69e6c99c2 100644 --- a/packages/core/src/__mocks__/connector.ts +++ b/packages/core/src/__mocks__/connector.ts @@ -14,7 +14,7 @@ export const mockMetadata: ConnectorMetadata = { 'pt-PT': 'Conector', 'zh-CN': '连接器', 'tr-TR': 'Connector', - 'ko-KR': 'Connector', + ko: 'Connector', }, logo: './logo.png', logoDark: './logo-dark.png', @@ -23,7 +23,7 @@ export const mockMetadata: ConnectorMetadata = { 'pt-PT': 'Conector', 'zh-CN': '连接器', 'tr-TR': 'Connector', - 'ko-KR': 'Connector', + ko: 'Connector', }, readme: 'README.md', configTemplate: 'config-template.json', diff --git a/packages/demo-app/package.json b/packages/demo-app/package.json index 0caf9ac1e..3fc980948 100644 --- a/packages/demo-app/package.json +++ b/packages/demo-app/package.json @@ -18,7 +18,7 @@ }, "devDependencies": { "@logto/core-kit": "1.0.0-beta.19", - "@logto/language-kit": "1.0.0-beta.19", + "@logto/language-kit": "1.0.0-beta.20", "@logto/phrases": "workspace:^", "@logto/react": "1.0.0-beta.10", "@logto/schemas": "workspace:^", diff --git a/packages/phrases-ui/package.json b/packages/phrases-ui/package.json index 58e66adf6..127c3f19c 100644 --- a/packages/phrases-ui/package.json +++ b/packages/phrases-ui/package.json @@ -32,9 +32,9 @@ }, "dependencies": { "@logto/core-kit": "1.0.0-beta.19", - "@logto/language-kit": "1.0.0-beta.19", + "@logto/language-kit": "1.0.0-beta.20", "@silverhand/essentials": "^1.3.0", - "zod": "^3.18.0" + "zod": "^3.19.1" }, "devDependencies": { "@silverhand/eslint-config": "1.3.0", diff --git a/packages/phrases-ui/src/index.ts b/packages/phrases-ui/src/index.ts index 947f9f012..792000a91 100644 --- a/packages/phrases-ui/src/index.ts +++ b/packages/phrases-ui/src/index.ts @@ -6,7 +6,7 @@ import { z } from 'zod'; import en from './locales/en'; import fr from './locales/fr'; -import koKR from './locales/ko-kr'; +import ko from './locales/ko'; import ptPT from './locales/pt-pt'; import trTR from './locales/tr-tr'; import zhCN from './locales/zh-cn'; @@ -16,7 +16,7 @@ export type { LocalePhrase } from './types'; export type I18nKey = NormalizeKeyPaths; -export const builtInLanguages = ['en', 'fr', 'pt-PT', 'zh-CN', 'ko-KR', 'tr-TR'] as const; +export const builtInLanguages = ['en', 'fr', 'pt-PT', 'zh-CN', 'ko', 'tr-TR'] as const; export const builtInLanguageOptions = builtInLanguages.map((languageTag) => ({ value: languageTag, @@ -34,7 +34,7 @@ const resource: Resource = { fr, 'pt-PT': ptPT, 'zh-CN': zhCN, - 'ko-KR': koKR, + ko, 'tr-TR': trTR, }; diff --git a/packages/phrases-ui/src/locales/ko-kr.ts b/packages/phrases-ui/src/locales/ko.ts similarity index 98% rename from packages/phrases-ui/src/locales/ko-kr.ts rename to packages/phrases-ui/src/locales/ko.ts index bfc617a0b..d2c54ba00 100644 --- a/packages/phrases-ui/src/locales/ko-kr.ts +++ b/packages/phrases-ui/src/locales/ko.ts @@ -80,8 +80,8 @@ const translation = { }, }; -const koKR: LocalePhrase = Object.freeze({ +const ko: LocalePhrase = Object.freeze({ translation, }); -export default koKR; +export default ko; diff --git a/packages/phrases/package.json b/packages/phrases/package.json index 0c64f0a50..917470953 100644 --- a/packages/phrases/package.json +++ b/packages/phrases/package.json @@ -32,9 +32,9 @@ }, "dependencies": { "@logto/core-kit": "1.0.0-beta.19", - "@logto/language-kit": "1.0.0-beta.19", + "@logto/language-kit": "1.0.0-beta.20", "@silverhand/essentials": "^1.3.0", - "zod": "^3.18.0" + "zod": "^3.19.1" }, "devDependencies": { "@silverhand/eslint-config": "1.3.0", diff --git a/packages/phrases/src/index.ts b/packages/phrases/src/index.ts index 2ee13dbbc..33f9efeaf 100644 --- a/packages/phrases/src/index.ts +++ b/packages/phrases/src/index.ts @@ -6,7 +6,7 @@ import { z } from 'zod'; import en from './locales/en'; import fr from './locales/fr'; -import koKR from './locales/ko-kr'; +import ko from './locales/ko'; import ptPT from './locales/pt-pt'; import trTR from './locales/tr-tr'; import zhCN from './locales/zh-cn'; @@ -16,7 +16,7 @@ export type { LocalPhrase } from './types'; export type I18nKey = NormalizeKeyPaths; -export const builtInLanguages = ['en', 'fr', 'pt-PT', 'zh-CN', 'ko-KR', 'tr-TR'] as const; +export const builtInLanguages = ['en', 'fr', 'pt-PT', 'zh-CN', 'ko', 'tr-TR'] as const; export const builtInLanguageOptions = builtInLanguages.map((languageTag) => ({ value: languageTag, @@ -46,7 +46,7 @@ const resource: Resource = { fr, 'pt-PT': ptPT, 'zh-CN': zhCN, - 'ko-KR': koKR, + ko, 'tr-TR': trTR, }; diff --git a/packages/phrases/src/locales/ko-kr/errors.ts b/packages/phrases/src/locales/ko/errors.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/errors.ts rename to packages/phrases/src/locales/ko/errors.ts diff --git a/packages/phrases/src/locales/ko-kr/index.ts b/packages/phrases/src/locales/ko/index.ts similarity index 70% rename from packages/phrases/src/locales/ko-kr/index.ts rename to packages/phrases/src/locales/ko/index.ts index d7ba7975c..a8e49ed0b 100644 --- a/packages/phrases/src/locales/ko-kr/index.ts +++ b/packages/phrases/src/locales/ko/index.ts @@ -2,9 +2,9 @@ import type { LocalPhrase } from '../../types'; import errors from './errors'; import translation from './translation'; -const koKR: LocalPhrase = Object.freeze({ +const ko: LocalPhrase = Object.freeze({ translation, errors, }); -export default koKR; +export default ko; diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/api-resource-details.ts b/packages/phrases/src/locales/ko/translation/admin-console/api-resource-details.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/api-resource-details.ts rename to packages/phrases/src/locales/ko/translation/admin-console/api-resource-details.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/api-resources.ts b/packages/phrases/src/locales/ko/translation/admin-console/api-resources.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/api-resources.ts rename to packages/phrases/src/locales/ko/translation/admin-console/api-resources.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/application-details.ts b/packages/phrases/src/locales/ko/translation/admin-console/application-details.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/application-details.ts rename to packages/phrases/src/locales/ko/translation/admin-console/application-details.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/applications.ts b/packages/phrases/src/locales/ko/translation/admin-console/applications.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/applications.ts rename to packages/phrases/src/locales/ko/translation/admin-console/applications.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/connector-details.ts b/packages/phrases/src/locales/ko/translation/admin-console/connector-details.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/connector-details.ts rename to packages/phrases/src/locales/ko/translation/admin-console/connector-details.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/connectors.ts b/packages/phrases/src/locales/ko/translation/admin-console/connectors.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/connectors.ts rename to packages/phrases/src/locales/ko/translation/admin-console/connectors.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/contact.ts b/packages/phrases/src/locales/ko/translation/admin-console/contact.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/contact.ts rename to packages/phrases/src/locales/ko/translation/admin-console/contact.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/dashboard.ts b/packages/phrases/src/locales/ko/translation/admin-console/dashboard.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/dashboard.ts rename to packages/phrases/src/locales/ko/translation/admin-console/dashboard.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/errors.ts b/packages/phrases/src/locales/ko/translation/admin-console/errors.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/errors.ts rename to packages/phrases/src/locales/ko/translation/admin-console/errors.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/general.ts b/packages/phrases/src/locales/ko/translation/admin-console/general.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/general.ts rename to packages/phrases/src/locales/ko/translation/admin-console/general.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/get-started.ts b/packages/phrases/src/locales/ko/translation/admin-console/get-started.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/get-started.ts rename to packages/phrases/src/locales/ko/translation/admin-console/get-started.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/index.ts b/packages/phrases/src/locales/ko/translation/admin-console/index.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/index.ts rename to packages/phrases/src/locales/ko/translation/admin-console/index.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/log-details.ts b/packages/phrases/src/locales/ko/translation/admin-console/log-details.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/log-details.ts rename to packages/phrases/src/locales/ko/translation/admin-console/log-details.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/logs.ts b/packages/phrases/src/locales/ko/translation/admin-console/logs.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/logs.ts rename to packages/phrases/src/locales/ko/translation/admin-console/logs.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/session-expired.ts b/packages/phrases/src/locales/ko/translation/admin-console/session-expired.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/session-expired.ts rename to packages/phrases/src/locales/ko/translation/admin-console/session-expired.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/settings.ts b/packages/phrases/src/locales/ko/translation/admin-console/settings.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/settings.ts rename to packages/phrases/src/locales/ko/translation/admin-console/settings.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/sign-in-exp.ts b/packages/phrases/src/locales/ko/translation/admin-console/sign-in-exp.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/sign-in-exp.ts rename to packages/phrases/src/locales/ko/translation/admin-console/sign-in-exp.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/tab-sections.ts b/packages/phrases/src/locales/ko/translation/admin-console/tab-sections.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/tab-sections.ts rename to packages/phrases/src/locales/ko/translation/admin-console/tab-sections.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/tabs.ts b/packages/phrases/src/locales/ko/translation/admin-console/tabs.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/tabs.ts rename to packages/phrases/src/locales/ko/translation/admin-console/tabs.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/user-details.ts b/packages/phrases/src/locales/ko/translation/admin-console/user-details.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/user-details.ts rename to packages/phrases/src/locales/ko/translation/admin-console/user-details.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/users.ts b/packages/phrases/src/locales/ko/translation/admin-console/users.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/users.ts rename to packages/phrases/src/locales/ko/translation/admin-console/users.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/admin-console/welcome.ts b/packages/phrases/src/locales/ko/translation/admin-console/welcome.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/admin-console/welcome.ts rename to packages/phrases/src/locales/ko/translation/admin-console/welcome.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/demo-app.ts b/packages/phrases/src/locales/ko/translation/demo-app.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/demo-app.ts rename to packages/phrases/src/locales/ko/translation/demo-app.ts diff --git a/packages/phrases/src/locales/ko-kr/translation/index.ts b/packages/phrases/src/locales/ko/translation/index.ts similarity index 100% rename from packages/phrases/src/locales/ko-kr/translation/index.ts rename to packages/phrases/src/locales/ko/translation/index.ts diff --git a/packages/schemas/package.json b/packages/schemas/package.json index 79a37b2b9..5ad641047 100644 --- a/packages/schemas/package.json +++ b/packages/schemas/package.json @@ -67,11 +67,11 @@ }, "prettier": "@silverhand/eslint-config/.prettierrc", "dependencies": { - "@logto/connector-kit": "1.0.0-beta.19", + "@logto/connector-kit": "1.0.0-beta.20", "@logto/core-kit": "1.0.0-beta.19", - "@logto/language-kit": "1.0.0-beta.19", + "@logto/language-kit": "1.0.0-beta.20", "@logto/phrases": "workspace:^", "@logto/phrases-ui": "workspace:^", - "zod": "^3.18.0" + "zod": "^3.19.1" } } diff --git a/packages/ui/package.json b/packages/ui/package.json index d745fc81a..491e39623 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -19,6 +19,7 @@ "@logto/core-kit": "1.0.0-beta.19" }, "devDependencies": { + "@logto/language-kit": "1.0.0-beta.20", "@logto/phrases": "workspace:^", "@logto/phrases-ui": "workspace:^", "@logto/schemas": "workspace:^", diff --git a/packages/ui/src/__mocks__/logto.tsx b/packages/ui/src/__mocks__/logto.tsx index e0067d726..94069bf8e 100644 --- a/packages/ui/src/__mocks__/logto.tsx +++ b/packages/ui/src/__mocks__/logto.tsx @@ -24,14 +24,14 @@ export const socialConnectors = [ 'pt-PT': 'Entrar com GitHub', 'zh-CN': '使用 GitHub 登录', 'tr-TR': 'Github ile giriş yap', - 'ko-KR': 'Github 로그인', + ko: 'Github 로그인', }, description: { en: 'Sign in with GitHub', 'pt-PT': 'Entrar com GitHub', 'zh-CN': '使用 GitHub 登录', 'tr-TR': 'Github ile giriş yap', - 'ko-KR': 'Github 로그인', + ko: 'Github 로그인', }, readme: '', configTemplate: '', @@ -48,14 +48,14 @@ export const socialConnectors = [ 'pt-PT': 'Entrar com Alipay', 'zh-CN': '使用 Alipay 登录', 'tr-TR': 'Alipay ile giriş yap', - 'ko-KR': 'Alipay 로그인', + ko: 'Alipay 로그인', }, description: { en: 'Sign in with Alipay', 'pt-PT': 'Entrar com Alipay', 'zh-CN': '使用 Alipay 登录', 'tr-TR': 'Alipay ile giriş yap', - 'ko-KR': 'Alipay 로그인', + ko: 'Alipay 로그인', }, readme: '', configTemplate: '', @@ -72,14 +72,14 @@ export const socialConnectors = [ 'pt-PT': 'Entrar com WeChat', 'zh-CN': '使用 WeChat 登录', 'tr-TR': 'WeChat ile giriş yap', - 'ko-KR': 'WeChat 로그인', + ko: 'WeChat 로그인', }, description: { en: 'Sign in with WeChat', 'pt-PT': 'Entrar com WeChat', 'zh-CN': '使用 WeChat 登录', 'tr-TR': 'WeChat ile giriş yap', - 'ko-KR': 'WeChat 로그인', + ko: 'WeChat 로그인', }, readme: '', configTemplate: '', @@ -96,14 +96,14 @@ export const socialConnectors = [ 'pt-PT': 'Entrar com Google', 'zh-CN': '使用 Google 登录', 'tr-TR': 'Google ile giriş yap', - 'ko-KR': 'Google 로그인', + ko: 'Google 로그인', }, description: { en: 'Sign in with Google', 'pt-PT': 'Entrar com Google', 'zh-CN': '使用 Google 登录', 'tr-TR': 'Google ile giriş yap', - 'ko-KR': 'Google 로그인', + ko: 'Google 로그인', }, readme: '', configTemplate: '', @@ -120,14 +120,14 @@ export const socialConnectors = [ 'pt-PT': 'Entrar com Facebook', 'zh-CN': '使用 Meta 登录', 'tr-TR': 'Meta ile giriş yap', - 'ko-KR': 'Meta 로그인', + ko: 'Meta 로그인', }, description: { en: 'Sign in with Meta', 'pt-PT': 'Entrar com Facebook', 'zh-CN': '使用 Meta 登录', 'tr-TR': 'Meta ile giriş yap', - 'ko-KR': 'Meta 로그인', + ko: 'Meta 로그인', }, readme: '', configTemplate: '', @@ -146,14 +146,14 @@ export const mockSocialConnectorData = { 'pt-PT': 'Entrar com Xxx', 'zh-CN': '使用 Xxx 登录', 'tr-TR': 'Xxx ile giriş yap', - 'ko-KR': 'Xxx 로그인', + ko: 'Xxx 로그인', }, description: { en: 'Sign in with Xxx', 'pt-PT': 'Entrar com Xxx', 'zh-CN': '使用 Xxx 登录', 'tr-TR': 'Xxx ile giriş yap', - 'ko-KR': 'Xxx 로그인', + ko: 'Xxx 로그인', }, readme: '', configTemplate: '', diff --git a/packages/ui/src/containers/SocialSignIn/SocialSignInDropdown/index.tsx b/packages/ui/src/containers/SocialSignIn/SocialSignInDropdown/index.tsx index 68452180d..ab7bbac0e 100644 --- a/packages/ui/src/containers/SocialSignIn/SocialSignInDropdown/index.tsx +++ b/packages/ui/src/containers/SocialSignIn/SocialSignInDropdown/index.tsx @@ -1,5 +1,6 @@ -import { getDefaultLanguage } from '@logto/core-kit'; +import { isLanguageTag } from '@logto/language-kit'; import type { ConnectorMetadata } from '@logto/schemas'; +import { conditional } from '@silverhand/essentials'; import { useState, useCallback } from 'react'; import { useTranslation } from 'react-i18next'; @@ -47,7 +48,7 @@ const SocialSignInDropdown = ({ isOpen, onClose, connectors, anchorRef }: Props) > {connectors.map((connector) => { const { id, name, logo, logoDark } = connector; - const localName = name[getDefaultLanguage(language)]; + const localName = conditional(isLanguageTag(language) && name[language]) ?? name.en; return ( =10'} - /zod/3.18.0: - resolution: {integrity: sha512-gwTm8RfUCe8l9rDwN5r2A17DkAa8Ez4Yl4yXqc5VqeGaXaJahzYYXbTwvhroZi0SNBqTwh/bKm2N0mpCzuw4bA==} + /zod/3.19.1: + resolution: {integrity: sha512-LYjZsEDhCdYET9ikFu6dVPGp2YH9DegXjdJToSzD9rO6fy4qiRYFoyEYwps88OseJlPyl2NOe2iJuhEhL7IpEA==} /zwitch/1.0.5: resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==}