@lingui/core 4.8.0 → 4.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +6 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -93,11 +93,11 @@ const selectFormatter = (value, rules) => rules[value] ?? rules.other;
|
|
|
93
93
|
function interpolate(translation, locale, locales) {
|
|
94
94
|
return (values = {}, formats) => {
|
|
95
95
|
const formatters = getDefaultFormats(locale, locales, formats);
|
|
96
|
-
const formatMessage = (tokens) => {
|
|
96
|
+
const formatMessage = (tokens, replaceOctothorpe = false) => {
|
|
97
97
|
if (!Array.isArray(tokens))
|
|
98
98
|
return tokens;
|
|
99
99
|
return tokens.reduce((message, token) => {
|
|
100
|
-
if (token === "#") {
|
|
100
|
+
if (token === "#" && replaceOctothorpe) {
|
|
101
101
|
return message + OCTOTHORPE_PH;
|
|
102
102
|
}
|
|
103
103
|
if (isString(token)) {
|
|
@@ -108,7 +108,10 @@ function interpolate(translation, locale, locales) {
|
|
|
108
108
|
if (type === "plural" || type === "selectordinal" || type === "select") {
|
|
109
109
|
Object.entries(format).forEach(
|
|
110
110
|
([key, value2]) => {
|
|
111
|
-
interpolatedFormat[key] = formatMessage(
|
|
111
|
+
interpolatedFormat[key] = formatMessage(
|
|
112
|
+
value2,
|
|
113
|
+
type === "plural" || type === "selectordinal"
|
|
114
|
+
);
|
|
112
115
|
}
|
|
113
116
|
);
|
|
114
117
|
} else {
|
package/dist/index.d.cts
CHANGED
|
@@ -43,7 +43,7 @@ type MissingMessageEvent = {
|
|
|
43
43
|
id: string;
|
|
44
44
|
};
|
|
45
45
|
type MissingHandler = string | ((locale: string, id: string) => string);
|
|
46
|
-
type
|
|
46
|
+
type I18nProps = {
|
|
47
47
|
locale?: Locale;
|
|
48
48
|
locales?: Locales;
|
|
49
49
|
messages?: AllMessages;
|
|
@@ -71,7 +71,7 @@ declare class I18n extends EventEmitter<Events> {
|
|
|
71
71
|
private _localeData;
|
|
72
72
|
private _messages;
|
|
73
73
|
private _missing?;
|
|
74
|
-
constructor(params:
|
|
74
|
+
constructor(params: I18nProps);
|
|
75
75
|
get locale(): string;
|
|
76
76
|
get locales(): Locales | undefined;
|
|
77
77
|
get messages(): Messages;
|
|
@@ -105,7 +105,7 @@ declare class I18n extends EventEmitter<Events> {
|
|
|
105
105
|
date(value: string | Date, format?: Intl.DateTimeFormatOptions): string;
|
|
106
106
|
number(value: number, format?: Intl.NumberFormatOptions): string;
|
|
107
107
|
}
|
|
108
|
-
declare function setupI18n(params?:
|
|
108
|
+
declare function setupI18n(params?: I18nProps): I18n;
|
|
109
109
|
|
|
110
110
|
declare const defaultLocale = "en";
|
|
111
111
|
declare function date(locales: Locales, value: string | Date, format?: Intl.DateTimeFormatOptions): string;
|
package/dist/index.d.mts
CHANGED
|
@@ -43,7 +43,7 @@ type MissingMessageEvent = {
|
|
|
43
43
|
id: string;
|
|
44
44
|
};
|
|
45
45
|
type MissingHandler = string | ((locale: string, id: string) => string);
|
|
46
|
-
type
|
|
46
|
+
type I18nProps = {
|
|
47
47
|
locale?: Locale;
|
|
48
48
|
locales?: Locales;
|
|
49
49
|
messages?: AllMessages;
|
|
@@ -71,7 +71,7 @@ declare class I18n extends EventEmitter<Events> {
|
|
|
71
71
|
private _localeData;
|
|
72
72
|
private _messages;
|
|
73
73
|
private _missing?;
|
|
74
|
-
constructor(params:
|
|
74
|
+
constructor(params: I18nProps);
|
|
75
75
|
get locale(): string;
|
|
76
76
|
get locales(): Locales | undefined;
|
|
77
77
|
get messages(): Messages;
|
|
@@ -105,7 +105,7 @@ declare class I18n extends EventEmitter<Events> {
|
|
|
105
105
|
date(value: string | Date, format?: Intl.DateTimeFormatOptions): string;
|
|
106
106
|
number(value: number, format?: Intl.NumberFormatOptions): string;
|
|
107
107
|
}
|
|
108
|
-
declare function setupI18n(params?:
|
|
108
|
+
declare function setupI18n(params?: I18nProps): I18n;
|
|
109
109
|
|
|
110
110
|
declare const defaultLocale = "en";
|
|
111
111
|
declare function date(locales: Locales, value: string | Date, format?: Intl.DateTimeFormatOptions): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ type MissingMessageEvent = {
|
|
|
43
43
|
id: string;
|
|
44
44
|
};
|
|
45
45
|
type MissingHandler = string | ((locale: string, id: string) => string);
|
|
46
|
-
type
|
|
46
|
+
type I18nProps = {
|
|
47
47
|
locale?: Locale;
|
|
48
48
|
locales?: Locales;
|
|
49
49
|
messages?: AllMessages;
|
|
@@ -71,7 +71,7 @@ declare class I18n extends EventEmitter<Events> {
|
|
|
71
71
|
private _localeData;
|
|
72
72
|
private _messages;
|
|
73
73
|
private _missing?;
|
|
74
|
-
constructor(params:
|
|
74
|
+
constructor(params: I18nProps);
|
|
75
75
|
get locale(): string;
|
|
76
76
|
get locales(): Locales | undefined;
|
|
77
77
|
get messages(): Messages;
|
|
@@ -105,7 +105,7 @@ declare class I18n extends EventEmitter<Events> {
|
|
|
105
105
|
date(value: string | Date, format?: Intl.DateTimeFormatOptions): string;
|
|
106
106
|
number(value: number, format?: Intl.NumberFormatOptions): string;
|
|
107
107
|
}
|
|
108
|
-
declare function setupI18n(params?:
|
|
108
|
+
declare function setupI18n(params?: I18nProps): I18n;
|
|
109
109
|
|
|
110
110
|
declare const defaultLocale = "en";
|
|
111
111
|
declare function date(locales: Locales, value: string | Date, format?: Intl.DateTimeFormatOptions): string;
|
package/dist/index.mjs
CHANGED
|
@@ -91,11 +91,11 @@ const selectFormatter = (value, rules) => rules[value] ?? rules.other;
|
|
|
91
91
|
function interpolate(translation, locale, locales) {
|
|
92
92
|
return (values = {}, formats) => {
|
|
93
93
|
const formatters = getDefaultFormats(locale, locales, formats);
|
|
94
|
-
const formatMessage = (tokens) => {
|
|
94
|
+
const formatMessage = (tokens, replaceOctothorpe = false) => {
|
|
95
95
|
if (!Array.isArray(tokens))
|
|
96
96
|
return tokens;
|
|
97
97
|
return tokens.reduce((message, token) => {
|
|
98
|
-
if (token === "#") {
|
|
98
|
+
if (token === "#" && replaceOctothorpe) {
|
|
99
99
|
return message + OCTOTHORPE_PH;
|
|
100
100
|
}
|
|
101
101
|
if (isString(token)) {
|
|
@@ -106,7 +106,10 @@ function interpolate(translation, locale, locales) {
|
|
|
106
106
|
if (type === "plural" || type === "selectordinal" || type === "select") {
|
|
107
107
|
Object.entries(format).forEach(
|
|
108
108
|
([key, value2]) => {
|
|
109
|
-
interpolatedFormat[key] = formatMessage(
|
|
109
|
+
interpolatedFormat[key] = formatMessage(
|
|
110
|
+
value2,
|
|
111
|
+
type === "plural" || type === "selectordinal"
|
|
112
|
+
);
|
|
110
113
|
}
|
|
111
114
|
);
|
|
112
115
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "I18n tools for javascript",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@babel/runtime": "^7.20.13",
|
|
57
|
-
"@lingui/message-utils": "4.
|
|
57
|
+
"@lingui/message-utils": "4.10.1",
|
|
58
58
|
"unraw": "^3.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@lingui/jest-mocks": "*",
|
|
62
62
|
"unbuild": "2.0.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "fbea0ab14b43a5ef7d31931cb76c263fd78f0481"
|
|
65
65
|
}
|