@lingui/macro
Advanced tools
Comparing version 4.11.2 to 5.0.0-next.0
356
index.d.ts
@@ -1,318 +0,98 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import type { ReactNode, VFC, FC } from "react" | ||
import type { I18n, MessageDescriptor } from "@lingui/core" | ||
import type { TransRenderCallbackOrComponent } from "@lingui/react" | ||
import { | ||
t as _t, | ||
plural as _plural, | ||
defineMessage as _defineMessage, | ||
msg as _msg, | ||
select as _select, | ||
selectOrdinal as _selectOrdinal, | ||
SelectOptions as _SelectOptions, | ||
ChoiceOptions as _ChoiceOptions, | ||
MacroMessageDescriptor as _MacroMessageDescriptor, | ||
} from "@lingui/core/macro" | ||
export type ChoiceOptions = { | ||
/** Offset of value when calculating plural forms */ | ||
offset?: number | ||
zero?: string | ||
one?: string | ||
two?: string | ||
few?: string | ||
many?: string | ||
import { | ||
Trans as _Trans, | ||
Plural as _Plural, | ||
Select as _Select, | ||
SelectOrdinal as _SelectOrdinal, | ||
PluralChoiceProps as _PluralChoiceProps, | ||
SelectChoiceProps as _SelectChoiceProps, | ||
CommonProps as _CommonProps, | ||
TransProps as _TransProps, | ||
useLingui as _useLingui, | ||
} from "@lingui/react/macro" | ||
/** Catch-all option */ | ||
other: string | ||
/** Exact match form, corresponds to =N rule */ | ||
[digit: `${number}`]: string | ||
} | ||
type MacroMessageDescriptor = ( | ||
| { | ||
id: string | ||
message?: string | ||
} | ||
| { | ||
id?: string | ||
message: string | ||
} | ||
) & { | ||
comment?: string | ||
context?: string | ||
} | ||
/** | ||
* Translates a message descriptor | ||
* | ||
* @example | ||
* ``` | ||
* import { t } from "@lingui/macro"; | ||
* const message = t({ | ||
* id: "msg.hello", | ||
* comment: "Greetings at the homepage", | ||
* message: `Hello ${name}`, | ||
* }); | ||
* ``` | ||
* | ||
* @example | ||
* ``` | ||
* import { t } from "@lingui/macro"; | ||
* const message = t({ | ||
* id: "msg.plural", | ||
* message: plural(value, { one: "...", other: "..." }), | ||
* }); | ||
* ``` | ||
* | ||
* @param descriptor The message descriptor to translate | ||
* @deprecated please import from `@lingui/core/macro` directly | ||
*/ | ||
export function t(descriptor: MacroMessageDescriptor): string | ||
declare const t: typeof _t | ||
/** | ||
* Translates a template string using the global I18n instance | ||
* | ||
* @example | ||
* ``` | ||
* import { t } from "@lingui/macro"; | ||
* const message = t`Hello ${name}`; | ||
* ``` | ||
* @deprecated please import from `@lingui/core/macro` directly | ||
*/ | ||
export function t( | ||
literals: TemplateStringsArray, | ||
...placeholders: any[] | ||
): string | ||
declare const msg: typeof _msg | ||
/** | ||
* Translates a template string or message descriptor using a given I18n instance | ||
* | ||
* @example | ||
* ``` | ||
* import { t } from "@lingui/macro"; | ||
* import { I18n } from "@lingui/core"; | ||
* const i18n = new I18n({ | ||
* locale: "nl", | ||
* messages: { "Hello {0}": "Hallo {0}" }, | ||
* }); | ||
* const message = t(i18n)`Hello ${name}`; | ||
* ``` | ||
* | ||
* @example | ||
* ``` | ||
* import { t } from "@lingui/macro"; | ||
* import { I18n } from "@lingui/core"; | ||
* const i18n = new I18n({ | ||
* locale: "nl", | ||
* messages: { "Hello {0}": "Hallo {0}" }, | ||
* }); | ||
* const message = t(i18n)({ message: `Hello ${name}` }); | ||
* ``` | ||
* @deprecated please import from `@lingui/core/macro` directly | ||
*/ | ||
export function t(i18n: I18n): { | ||
(literals: TemplateStringsArray, ...placeholders: any[]): string | ||
(descriptor: MacroMessageDescriptor): string | ||
} | ||
declare const plural: typeof _plural | ||
/** | ||
* Pluralize a message | ||
* | ||
* @example | ||
* ``` | ||
* import { plural } from "@lingui/macro"; | ||
* const message = plural(count, { | ||
* one: "# Book", | ||
* other: "# Books", | ||
* }); | ||
* ``` | ||
* | ||
* @param value Determines the plural form | ||
* @param options Object with available plural forms | ||
* @deprecated please import from `@lingui/core/macro` directly | ||
*/ | ||
export function plural(value: number | string, options: ChoiceOptions): string | ||
declare const defineMessage: typeof _defineMessage | ||
/** | ||
* Pluralize a message using ordinal forms | ||
* | ||
* Similar to `plural` but instead of using cardinal plural forms, | ||
* it uses ordinal forms. | ||
* | ||
* @example | ||
* ``` | ||
* import { selectOrdinal } from "@lingui/macro"; | ||
* const message = selectOrdinal(count, { | ||
* one: "#st", | ||
* two: "#nd", | ||
* few: "#rd", | ||
* other: "#th", | ||
* }); | ||
* ``` | ||
* | ||
* @param value Determines the plural form | ||
* @param options Object with available plural forms | ||
* @deprecated please import from `@lingui/core/macro` directly | ||
*/ | ||
export function selectOrdinal( | ||
value: number | string, | ||
options: ChoiceOptions | ||
): string | ||
type SelectOptions = { | ||
/** Catch-all option */ | ||
other: string | ||
[matches: string]: string | ||
} | ||
declare const select: typeof _select | ||
/** | ||
* Selects a translation based on a value | ||
* | ||
* Select works like a switch statement. It will | ||
* select one of the forms in `options` object which | ||
* key matches exactly `value`. | ||
* | ||
* @example | ||
* ``` | ||
* import { select } from "@lingui/macro"; | ||
* const message = select(gender, { | ||
* male: "he", | ||
* female: "she", | ||
* other: "they", | ||
* }); | ||
* ``` | ||
* | ||
* @param value The key of choices to use | ||
* @param choices | ||
* @deprecated please import from `@lingui/core/macro` directly | ||
*/ | ||
export function select(value: string, choices: SelectOptions): string | ||
declare const selectOrdinal: typeof _selectOrdinal | ||
/** | ||
* Define a message for later use | ||
* | ||
* `defineMessage` can be used to add comments for translators, | ||
* or to override the message ID. | ||
* | ||
* @example | ||
* ``` | ||
* import { defineMessage } from "@lingui/macro"; | ||
* const message = defineMessage({ | ||
* comment: "Greetings on the welcome page", | ||
* message: `Welcome, ${name}!`, | ||
* }); | ||
* ``` | ||
* | ||
* @param descriptor The message descriptor | ||
* @deprecated please import from `@lingui/core/macro` directly | ||
*/ | ||
export function defineMessage( | ||
descriptor: MacroMessageDescriptor | ||
): MessageDescriptor | ||
declare const SelectOptions: _SelectOptions | ||
/** | ||
* Define a message for later use | ||
* | ||
* @example | ||
* ``` | ||
* import { defineMessage, msg } from "@lingui/macro"; | ||
* const message = defineMessage`Hello ${name}`; | ||
* | ||
* // or using shorter version | ||
* const message = msg`Hello ${name}`; | ||
* ``` | ||
* @deprecated please import from `@lingui/core/macro` directly | ||
*/ | ||
export function defineMessage( | ||
literals: TemplateStringsArray, | ||
...placeholders: any[] | ||
): MessageDescriptor | ||
declare const ChoiceOptions: _ChoiceOptions | ||
/** | ||
* Define a message for later use | ||
* Alias for {@see defineMessage} | ||
* @deprecated please import from `@lingui/core/macro` directly | ||
*/ | ||
export const msg: typeof defineMessage | ||
declare const MacroMessageDescriptor: _MacroMessageDescriptor | ||
type CommonProps = TransRenderCallbackOrComponent & { | ||
id?: string | ||
comment?: string | ||
context?: string | ||
} | ||
type TransProps = { | ||
children: ReactNode | ||
} & CommonProps | ||
type PluralChoiceProps = { | ||
value: string | number | ||
/** Offset of value when calculating plural forms */ | ||
offset?: number | ||
zero?: ReactNode | ||
one?: ReactNode | ||
two?: ReactNode | ||
few?: ReactNode | ||
many?: ReactNode | ||
/** Catch-all option */ | ||
other: ReactNode | ||
/** Exact match form, corresponds to =N rule */ | ||
[digit: `_${number}`]: ReactNode | ||
} & CommonProps | ||
type SelectChoiceProps = { | ||
value: string | ||
/** Catch-all option */ | ||
other: ReactNode | ||
[option: `_${string}`]: ReactNode | ||
} & CommonProps | ||
/** | ||
* Trans is the basic macro for static messages, | ||
* messages with variables, but also for messages with inline markup | ||
* | ||
* @example | ||
* ``` | ||
* <Trans>Hello {username}. Read the <a href="/docs">docs</a>.</Trans> | ||
* ``` | ||
* @example | ||
* ``` | ||
* <Trans id="custom.id">Hello {username}.</Trans> | ||
* ``` | ||
* @deprecated please import from `@lingui/react/macro` directly | ||
*/ | ||
export const Trans: FC<TransProps> | ||
declare const Trans: typeof _Trans | ||
/** | ||
* Props of Plural macro are transformed into plural format. | ||
* | ||
* @example | ||
* ``` | ||
* import { Plural } from "@lingui/macro" | ||
* <Plural value={numBooks} one="Book" other="Books" /> | ||
* | ||
* // ↓ ↓ ↓ ↓ ↓ ↓ | ||
* import { Trans } from "@lingui/react" | ||
* <Trans id="{numBooks, plural, one {Book} other {Books}}" values={{ numBooks }} /> | ||
* ``` | ||
* @deprecated please import from `@lingui/react/macro` directly | ||
*/ | ||
export const Plural: VFC<PluralChoiceProps> | ||
export const Plural: typeof _Plural | ||
/** | ||
* Props of SelectOrdinal macro are transformed into selectOrdinal format. | ||
* | ||
* @example | ||
* ``` | ||
* // count == 1 -> 1st | ||
* // count == 2 -> 2nd | ||
* // count == 3 -> 3rd | ||
* // count == 4 -> 4th | ||
* <SelectOrdinal | ||
* value={count} | ||
* one="#st" | ||
* two="#nd" | ||
* few="#rd" | ||
* other="#th" | ||
* /> | ||
* ``` | ||
* @deprecated please import from `@lingui/react/macro` directly | ||
*/ | ||
export const SelectOrdinal: VFC<PluralChoiceProps> | ||
export const PluralChoiceProps: _PluralChoiceProps | ||
/** | ||
* Props of Select macro are transformed into select format | ||
* | ||
* @example | ||
* ``` | ||
* // gender == "female" -> Her book | ||
* // gender == "male" -> His book | ||
* // gender == "non-binary" -> Their book | ||
* | ||
* <Select | ||
* value={gender} | ||
* _male="His book" | ||
* _female="Her book" | ||
* other="Their book" | ||
* /> | ||
* ``` | ||
* @deprecated please import from `@lingui/react/macro` directly | ||
*/ | ||
export const Select: VFC<SelectChoiceProps> | ||
export const SelectChoiceProps: _SelectChoiceProps | ||
/** | ||
* @deprecated please import from `@lingui/react/macro` directly | ||
*/ | ||
export const Select: typeof _Select | ||
/** | ||
* @deprecated please import from `@lingui/react/macro` directly | ||
*/ | ||
export const CommonProps: _CommonProps | ||
/** | ||
* @deprecated please import from `@lingui/react/macro` directly | ||
*/ | ||
export const SelectOrdinal: typeof _SelectOrdinal | ||
/** | ||
* @deprecated please import from `@lingui/react/macro` directly | ||
*/ | ||
export const TransProps: _TransProps | ||
/** | ||
* @deprecated please import from `@lingui/react/macro` directly | ||
*/ | ||
export const useLingui: typeof _useLingui |
{ | ||
"name": "@lingui/macro", | ||
"version": "4.11.2", | ||
"version": "5.0.0-next.0", | ||
"description": "Macro for generating messages in ICU MessageFormat syntax", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.mjs", | ||
"main": "./index.js", | ||
"types": "./index.d.ts", | ||
@@ -14,5 +13,3 @@ "sideEffects": false, | ||
"scripts": { | ||
"test:tsd": "tsd", | ||
"build": "rimraf ./dist && unbuild", | ||
"stub": "unbuild --stub" | ||
"test:tsd": "tsd" | ||
}, | ||
@@ -42,18 +39,4 @@ "license": "MIT", | ||
".": { | ||
"require": { | ||
"types": "./index.d.ts", | ||
"default": "./dist/index.cjs" | ||
}, | ||
"import": { | ||
"types": "./index.d.ts", | ||
"default": "./dist/index.mjs" | ||
} | ||
}, | ||
"./node": { | ||
"require": { | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"import": { | ||
"types": "./dist/index.d.ts" | ||
} | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
} | ||
@@ -65,25 +48,22 @@ }, | ||
"dist/", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"@babel/runtime": "^7.20.13", | ||
"@babel/types": "^7.20.7", | ||
"@lingui/conf": "4.11.2", | ||
"@lingui/core": "4.11.2", | ||
"@lingui/message-utils": "4.11.2" | ||
"@lingui/core": "^5.0.0-next.0", | ||
"@lingui/react": "^5.0.0-next.0" | ||
}, | ||
"peerDependencies": { | ||
"@lingui/react": "^4.0.0", | ||
"@lingui/babel-plugin-lingui-macro": "4.11.2", | ||
"babel-plugin-macros": "2 || 3" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.20.12", | ||
"@babel/parser": "7.20.15", | ||
"@babel/traverse": "7.20.12", | ||
"@types/babel-plugin-macros": "^2.8.5", | ||
"prettier": "2.8.3", | ||
"tsd": "^0.26.1", | ||
"unbuild": "2.0.0" | ||
"peerDependenciesMeta": { | ||
"@lingui/babel-plugin-lingui-macro": { | ||
"optional": true | ||
}, | ||
"babel-plugin-macros": { | ||
"optional": true | ||
} | ||
}, | ||
"gitHead": "17e0af54b0b9d9577db2cef1be680a6d871611e7" | ||
"gitHead": "2192f8d54699a3846ff8fe6f3992697be2da68a8" | ||
} |
@@ -27,3 +27,3 @@ [![License][badge-license]][license] | ||
import { setupI18n } from "@lingui/core" | ||
import { t } from "@lingui/macro" | ||
import { t } from "@lingui/core/macro" | ||
@@ -30,0 +30,0 @@ const i18n = setupI18n() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
0
11
2
71111
1912
2
+ Added@lingui/react@^5.0.0-next.0
+ Added@lingui/core@5.0.0-next.0(transitive)
+ Added@lingui/message-utils@5.0.0-next.0(transitive)
+ Added@lingui/react@5.0.0-next.0(transitive)
- Removed@babel/runtime@^7.20.13
- Removed@babel/types@^7.20.7
- Removed@lingui/conf@4.11.2
- Removed@lingui/message-utils@4.11.2
- Removed@babel/helper-string-parser@7.24.8(transitive)
- Removed@babel/types@7.25.2(transitive)
- Removed@jest/schemas@29.6.3(transitive)
- Removed@jest/types@29.6.3(transitive)
- Removed@lingui/conf@4.11.2(transitive)
- Removed@lingui/core@4.11.24.11.3(transitive)
- Removed@lingui/message-utils@4.11.24.11.3(transitive)
- Removed@lingui/react@4.11.3(transitive)
- Removed@sinclair/typebox@0.27.8(transitive)
- Removed@types/istanbul-lib-coverage@2.0.6(transitive)
- Removed@types/istanbul-lib-report@3.0.3(transitive)
- Removed@types/istanbul-reports@3.0.4(transitive)
- Removed@types/node@22.5.0(transitive)
- Removed@types/yargs@17.0.33(transitive)
- Removed@types/yargs-parser@21.0.3(transitive)
- Removedansi-styles@4.3.05.2.0(transitive)
- Removedargparse@2.0.1(transitive)
- Removedcamelcase@6.3.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedcosmiconfig@8.3.6(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedjest-get-type@29.6.3(transitive)
- Removedjest-validate@29.7.0(transitive)
- Removedjiti@1.21.6(transitive)
- Removedjs-yaml@4.1.0(transitive)
- Removedleven@3.1.0(transitive)
- Removedlodash.get@4.4.2(transitive)
- Removedpretty-format@29.7.0(transitive)
- Removedreact-is@18.3.1(transitive)
- Removedsupports-color@7.2.0(transitive)
- Removedto-fast-properties@2.0.0(transitive)
- Removedundici-types@6.19.8(transitive)
Updated@lingui/core@^5.0.0-next.0