mirror of
https://github.com/logto-io/logto.git
synced 2025-01-27 21:39:16 -05:00
refactor(phrases): fix type issue
This commit is contained in:
parent
37714d153c
commit
362f6a5863
16 changed files with 28 additions and 30 deletions
|
@ -1,10 +1,10 @@
|
|||
// https://react.i18next.com/latest/typescript#create-a-declaration-file
|
||||
|
||||
import type { LocalPhrase } from '@logto/phrases';
|
||||
import type { LocalePhrase } from '@logto/phrases';
|
||||
|
||||
declare module 'react-i18next' {
|
||||
interface CustomTypeOptions {
|
||||
allowObjectInHTMLChildren: true;
|
||||
resources: LocalPhrase;
|
||||
resources: LocalePhrase;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import en from '@logto/phrases-ui/lib/locales/en.js';
|
||||
import en from '@logto/phrases-ui/lib/locales/en/index.js';
|
||||
import { type CustomPhrase } from '@logto/schemas';
|
||||
|
||||
import { mockId } from '#src/test-utils/nanoid.js';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import en from '@logto/phrases-ui/lib/locales/en.js';
|
||||
import en from '@logto/phrases-ui/lib/locales/en/index.js';
|
||||
import { type CustomPhrase, type SignInExperience } from '@logto/schemas';
|
||||
import { pickDefault, createMockUtils } from '@logto/shared/esm';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import en from '@logto/phrases-ui/lib/locales/en.js';
|
||||
import en from '@logto/phrases-ui/lib/locales/en/index.js';
|
||||
import type { SignInExperience } from '@logto/schemas';
|
||||
import { pickDefault } from '@logto/shared/esm';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import en from '@logto/phrases-ui/lib/locales/en.js';
|
||||
import en from '@logto/phrases-ui/lib/locales/en/index.js';
|
||||
import fr from '@logto/phrases-ui/lib/locales/fr.js';
|
||||
|
||||
import { isStrictlyPartial } from '#src/utils/translation.js';
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// https://react.i18next.com/latest/typescript#create-a-declaration-file
|
||||
|
||||
import type { LocalPhrase } from '@logto/phrases';
|
||||
import type { LocalePhrase } from '@logto/phrases';
|
||||
// eslint-disable-next-line unused-imports/no-unused-imports
|
||||
import { CustomTypeOptions } from 'react-i18next';
|
||||
|
||||
declare module 'react-i18next' {
|
||||
interface CustomTypeOptions {
|
||||
allowObjectInHTMLChildren: true;
|
||||
resources: LocalPhrase;
|
||||
resources: LocalePhrase;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ import ptBR from './locales/pt-br/index.js';
|
|||
import ptPT from './locales/pt-pt/index.js';
|
||||
import trTR from './locales/tr-tr/index.js';
|
||||
import zhCN from './locales/zh-cn/index.js';
|
||||
import type { LocalPhrase } from './types.js';
|
||||
import type { LocalePhrase } from './types.js';
|
||||
|
||||
export type { LocalPhrase } from './types.js';
|
||||
export type { LocalePhrase } from './types.js';
|
||||
|
||||
export type I18nKey = NormalizeKeyPaths<typeof en.translation>;
|
||||
|
||||
|
@ -51,7 +51,7 @@ export const getDefaultLanguageTag = (languages: string): LanguageTag =>
|
|||
export const isBuiltInLanguageTag = (language: string): language is BuiltInLanguageTag =>
|
||||
builtInLanguageTagGuard.safeParse(language).success;
|
||||
|
||||
export type Resource = Record<BuiltInLanguageTag, LocalPhrase>;
|
||||
export type Resource = Record<BuiltInLanguageTag, LocalePhrase>;
|
||||
|
||||
const resource: Resource = {
|
||||
de,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { LocalPhrase } from '../../types.js';
|
||||
import type { LocalePhrase } from '../../types.js';
|
||||
|
||||
import errors from './errors.js';
|
||||
import translation from './translation/index.js';
|
||||
|
||||
const de: LocalPhrase = Object.freeze({
|
||||
const de: LocalePhrase = Object.freeze({
|
||||
translation,
|
||||
errors,
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { LocalPhrase } from '../../types.js';
|
||||
import type { LocalePhrase } from '../../types.js';
|
||||
|
||||
import errors from './errors.js';
|
||||
import translation from './translation/index.js';
|
||||
|
||||
const fr: LocalPhrase = Object.freeze({
|
||||
const fr: LocalePhrase = Object.freeze({
|
||||
translation,
|
||||
errors,
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { LocalPhrase } from '../../types.js';
|
||||
import type { LocalePhrase } from '../../types.js';
|
||||
|
||||
import errors from './errors.js';
|
||||
import translation from './translation/index.js';
|
||||
|
||||
const ko: LocalPhrase = Object.freeze({
|
||||
const ko: LocalePhrase = Object.freeze({
|
||||
translation,
|
||||
errors,
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { LocalPhrase } from '../../types.js';
|
||||
import type { LocalePhrase } from '../../types.js';
|
||||
|
||||
import errors from './errors.js';
|
||||
import translation from './translation/index.js';
|
||||
|
||||
const ptBR: LocalPhrase = Object.freeze({
|
||||
const ptBR: LocalePhrase = Object.freeze({
|
||||
translation,
|
||||
errors,
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { LocalPhrase } from '../../types.js';
|
||||
import type { LocalePhrase } from '../../types.js';
|
||||
|
||||
import errors from './errors.js';
|
||||
import translation from './translation/index.js';
|
||||
|
||||
const ptPT: LocalPhrase = Object.freeze({
|
||||
const ptPT: LocalePhrase = Object.freeze({
|
||||
translation,
|
||||
errors,
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { LocalPhrase } from '../../types.js';
|
||||
import type { LocalePhrase } from '../../types.js';
|
||||
|
||||
import errors from './errors.js';
|
||||
import translation from './translation/index.js';
|
||||
|
||||
const trTR: LocalPhrase = Object.freeze({
|
||||
const trTR: LocalePhrase = Object.freeze({
|
||||
translation,
|
||||
errors,
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import type { LocalPhrase } from '../../types.js';
|
||||
import type { LocalePhrase } from '../../types.js';
|
||||
|
||||
import errors from './errors.js';
|
||||
import translation from './translation/index.js';
|
||||
|
||||
const zhCN: LocalPhrase = Object.freeze({
|
||||
const zhCN: LocalePhrase = Object.freeze({
|
||||
translation,
|
||||
errors,
|
||||
});
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import type en from './locales/en/index.js';
|
||||
|
||||
export type LocalPhrase = typeof en;
|
||||
export type LocalePhrase = typeof en;
|
||||
|
|
6
packages/ui/src/include.d/react-i18next.d.ts
vendored
6
packages/ui/src/include.d/react-i18next.d.ts
vendored
|
@ -1,12 +1,10 @@
|
|||
// https://react.i18next.com/latest/typescript#create-a-declaration-file
|
||||
|
||||
// eslint-disable-next-line import/no-unassigned-import
|
||||
import 'react-i18next';
|
||||
import type en from '@logto/phrases-ui/lib/locales/en.js';
|
||||
import type { LocalePhrase } from '@logto/phrases-ui';
|
||||
|
||||
declare module 'react-i18next' {
|
||||
interface CustomTypeOptions {
|
||||
allowObjectInHTMLChildren: true;
|
||||
resources: typeof en;
|
||||
resources: LocalePhrase;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue