@lingui/core
Advanced tools
Comparing version 5.1.2 to 5.2.0
@@ -130,3 +130,5 @@ import { CompiledMessage } from '@lingui/message-utils/compileMessage'; | ||
declare const defaultLocale = "en"; | ||
declare function date(locales: Locales, value: string | Date, format?: Intl.DateTimeFormatOptions): string; | ||
type DateTimeFormatSize = "short" | "default" | "long" | "full"; | ||
declare function date(locales: Locales, value: string | Date, format?: Intl.DateTimeFormatOptions | DateTimeFormatSize): string; | ||
declare function time(locales: Locales, value: string | Date, format?: Intl.DateTimeFormatOptions | DateTimeFormatSize): string; | ||
declare function number(locales: Locales, value: number, format?: Intl.NumberFormatOptions): string; | ||
@@ -141,2 +143,3 @@ type PluralOptions = { | ||
type formats_DateTimeFormatSize = DateTimeFormatSize; | ||
type formats_PluralOptions = PluralOptions; | ||
@@ -147,4 +150,5 @@ declare const formats_date: typeof date; | ||
declare const formats_plural: typeof plural; | ||
declare const formats_time: typeof time; | ||
declare namespace formats { | ||
export { type formats_PluralOptions as PluralOptions, formats_date as date, formats_defaultLocale as defaultLocale, formats_number as number, formats_plural as plural }; | ||
export { type formats_DateTimeFormatSize as DateTimeFormatSize, type formats_PluralOptions as PluralOptions, formats_date as date, formats_defaultLocale as defaultLocale, formats_number as number, formats_plural as plural, formats_time as time }; | ||
} | ||
@@ -151,0 +155,0 @@ |
@@ -41,3 +41,3 @@ import type { I18n, MessageDescriptor } from "@lingui/core" | ||
* comment: "Greetings at the homepage", | ||
* message: `Hello ${name}`, | ||
* message: `Hello ${{name}}`, | ||
* }); | ||
@@ -59,2 +59,8 @@ * ``` | ||
export type LabeledExpression<T> = Record<string, T> | ||
export type MessagePlaceholder = | ||
| string | ||
| number | ||
| LabeledExpression<string | number> | ||
/** | ||
@@ -66,3 +72,3 @@ * Translates a template string using the global I18n instance | ||
* import { t } from "@lingui/core/macro"; | ||
* const message = t`Hello ${name}`; | ||
* const message = t`Hello ${{name}}`; | ||
* ``` | ||
@@ -72,3 +78,3 @@ */ | ||
literals: TemplateStringsArray, | ||
...placeholders: any[] | ||
...placeholders: MessagePlaceholder[] | ||
): string | ||
@@ -85,5 +91,5 @@ | ||
* locale: "nl", | ||
* messages: { "Hello {name}": "Hallo {name}" }, | ||
* messages: { "Hello {{name}}": "Hallo {{name}}" }, | ||
* }); | ||
* const message = t(i18n)`Hello ${name}`; | ||
* const message = t(i18n)`Hello ${{name}}`; | ||
* ``` | ||
@@ -97,9 +103,9 @@ * | ||
* locale: "nl", | ||
* messages: { "Hello {name}": "Hallo {name}" }, | ||
* messages: { "Hello {{name}}": "Hallo {{name}}" }, | ||
* }); | ||
* const message = t(i18n)({ message: `Hello ${name}` }); | ||
* const message = t(i18n)({ message: `Hello ${{name}}` }); | ||
* ``` | ||
* | ||
* @deprecated in v5, would be removed in v6. | ||
* Please use `` i18n._(msg`Hello ${name}`) `` instead | ||
* Please use `` i18n._(msg`Hello ${{name}}`) `` instead | ||
* | ||
@@ -118,3 +124,3 @@ */ | ||
* import { plural } from "@lingui/core/macro"; | ||
* const message = plural(count, { | ||
* const message = plural({count}, { | ||
* one: "# Book", | ||
@@ -128,3 +134,6 @@ * other: "# Books", | ||
*/ | ||
export function plural(value: number | string, options: ChoiceOptions): string | ||
export function plural( | ||
value: number | string | LabeledExpression<number | string>, | ||
options: ChoiceOptions | ||
): string | ||
@@ -140,3 +149,3 @@ /** | ||
* import { selectOrdinal } from "@lingui/core/macro"; | ||
* const message = selectOrdinal(count, { | ||
* const message = selectOrdinal({count}, { | ||
* one: "#st", | ||
@@ -153,3 +162,3 @@ * two: "#nd", | ||
export function selectOrdinal( | ||
value: number | string, | ||
value: number | string | LabeledExpression<number | string>, | ||
options: ChoiceOptions | ||
@@ -174,3 +183,3 @@ ): string | ||
* import { select } from "@lingui/core/macro"; | ||
* const message = select(gender, { | ||
* const message = select({gender}, { | ||
* male: "he", | ||
@@ -185,3 +194,6 @@ * female: "she", | ||
*/ | ||
export function select(value: string, choices: SelectOptions): string | ||
export function select( | ||
value: string | LabeledExpression<string>, | ||
choices: SelectOptions | ||
): string | ||
@@ -199,3 +211,3 @@ /** | ||
* comment: "Greetings on the welcome page", | ||
* message: `Welcome, ${name}!`, | ||
* message: `Welcome, ${{name}}!`, | ||
* }); | ||
@@ -216,6 +228,6 @@ * ``` | ||
* import { defineMessage, msg } from "@lingui/core/macro"; | ||
* const message = defineMessage`Hello ${name}`; | ||
* const message = defineMessage`Hello ${{name}}`; | ||
* | ||
* // or using shorter version | ||
* const message = msg`Hello ${name}`; | ||
* const message = msg`Hello ${{name}}`; | ||
* ``` | ||
@@ -225,3 +237,3 @@ */ | ||
literals: TemplateStringsArray, | ||
...placeholders: any[] | ||
...placeholders: MessagePlaceholder[] | ||
): MessageDescriptor | ||
@@ -234,1 +246,6 @@ | ||
export const msg: typeof defineMessage | ||
/** | ||
* Helps to define a name for a variable in the message | ||
*/ | ||
export function ph(def: LabeledExpression<string | number>): string |
{ | ||
"name": "@lingui/core", | ||
"version": "5.1.2", | ||
"version": "5.2.0", | ||
"sideEffects": false, | ||
@@ -63,7 +63,7 @@ "description": "I18n tools for javascript", | ||
"@babel/runtime": "^7.20.13", | ||
"@lingui/message-utils": "^5.1.2", | ||
"@lingui/message-utils": "5.2.0", | ||
"unraw": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@lingui/jest-mocks": "^3.0.3", | ||
"@lingui/jest-mocks": "*", | ||
"tsd": "^0.26.1", | ||
@@ -73,3 +73,3 @@ "unbuild": "2.0.0" | ||
"peerDependencies": { | ||
"@lingui/babel-plugin-lingui-macro": "5.1.2", | ||
"@lingui/babel-plugin-lingui-macro": "5.2.0", | ||
"babel-plugin-macros": "2 || 3" | ||
@@ -85,3 +85,3 @@ }, | ||
}, | ||
"gitHead": "e45a2af5dfc1c88131fa8196d596e0f0f25678ea" | ||
"gitHead": "9c50b4877ca8b134d0d96c09a8055221ca70b095" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
53107
1189
+ Added@lingui/babel-plugin-lingui-macro@5.2.0(transitive)
+ Addedelectron-to-chromium@1.5.97(transitive)
- Removed@lingui/babel-plugin-lingui-macro@5.1.2(transitive)
- Removedelectron-to-chromium@1.5.96(transitive)
Updated@lingui/message-utils@5.2.0