Skip to content

Commit

Permalink
fix: param name for missing in setupI18nProps (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
taozhou-glean committed Feb 10, 2023
1 parent acc84e7 commit 6459f02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ export type MissingMessageEvent = {
context?: string
}

type MissingHandler =
| string
| ((locale: string, id: string, context: string) => string)

type setupI18nProps = {
locale?: Locale
locales?: Locales
messages?: AllMessages
localeData?: AllLocaleData
missing?: string | ((message: string, id: string, context: string) => string)
missing?: MissingHandler
}

type Events = {
Expand All @@ -71,7 +75,7 @@ export class I18n extends EventEmitter<Events> {
private _locales: Locales
private _localeData: AllLocaleData
private _messages: AllMessages
private _missing: string | ((message, id, context) => string)
private _missing: MissingHandler

constructor(params: setupI18nProps) {
super()
Expand Down
6 changes: 3 additions & 3 deletions website/docs/ref/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ const i18n = setupI18n({ missing: "🚨" })
i18n._('missing translation') === "🚨"
```

This might be also a function which is called with active language and message ID:
This might be also a function which is called with active locale and message ID:

``` jsx
import { setupI18n } from "@lingui/core"

function missing(language, id) {
alert(`Translation in ${language} for ${id} is missing!`)
function missing(locale, id) {
alert(`Translation in ${locale} for ${id} is missing!`)
return id
}

Expand Down

1 comment on commit 6459f02

@vercel
Copy link

@vercel vercel bot commented on 6459f02 Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.