Socket
Socket
Sign inDemoInstall

@lingui/macro

Package Overview
Dependencies
Maintainers
0
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.11.2 to 5.0.0-next.0

./index.js

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()

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc