@lingui/format-po-gettext 5.7.0 → 5.8.0
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/po-gettext.cjs +5 -3
- package/dist/po-gettext.d.cts +13 -0
- package/dist/po-gettext.d.mts +13 -0
- package/dist/po-gettext.d.ts +13 -0
- package/dist/po-gettext.mjs +5 -3
- package/package.json +5 -5
package/dist/po-gettext.cjs
CHANGED
|
@@ -92,7 +92,7 @@ const ICU_PLURAL_REGEX = /^{.*, plural, .*}$/;
|
|
|
92
92
|
const ICU_SELECT_REGEX = /^{.*, select(Ordinal)?, .*}$/;
|
|
93
93
|
const LINE_ENDINGS = /\r?\n/g;
|
|
94
94
|
const DEFAULT_CTX_PREFIX = "js-lingui:";
|
|
95
|
-
function serializePlurals(item, message, id, isGeneratedId, options) {
|
|
95
|
+
function serializePlurals(item, message, id, isGeneratedId, options, formatterCtx) {
|
|
96
96
|
const icuMessage = message.message;
|
|
97
97
|
const ctxPrefix = options.customICUPrefix || DEFAULT_CTX_PREFIX;
|
|
98
98
|
if (!icuMessage) {
|
|
@@ -133,6 +133,8 @@ function serializePlurals(item, message, id, isGeneratedId, options) {
|
|
|
133
133
|
} else {
|
|
134
134
|
item.msgstr = ast.cases.map(stringifyICUCase);
|
|
135
135
|
}
|
|
136
|
+
} else if (!isGeneratedId && (formatterCtx.locale === formatterCtx.sourceLocale || formatterCtx.locale === null)) {
|
|
137
|
+
item.msgstr = messageAst.cases.map(stringifyICUCase);
|
|
136
138
|
}
|
|
137
139
|
} catch (e) {
|
|
138
140
|
console.error(`Error parsing message ICU for key "${id}":`, e);
|
|
@@ -262,7 +264,7 @@ function serializeContextToComment(ctx) {
|
|
|
262
264
|
urlParams.set("pluralize_on", ctx.pluralizeOn.join(","));
|
|
263
265
|
}
|
|
264
266
|
urlParams.sort();
|
|
265
|
-
return urlParams.toString()
|
|
267
|
+
return urlParams.toString();
|
|
266
268
|
}
|
|
267
269
|
function getContextFromComments(extractedComments, ctxPrefix) {
|
|
268
270
|
const contextComment = extractedComments.find(
|
|
@@ -406,7 +408,7 @@ function formatter(options = {}) {
|
|
|
406
408
|
);
|
|
407
409
|
const id = isGeneratedId ? generateMessageId.generateMessageId(item.msgid, item.msgctxt) : item.msgid;
|
|
408
410
|
const message = catalog[id];
|
|
409
|
-
return serializePlurals(item, message, id, isGeneratedId, options);
|
|
411
|
+
return serializePlurals(item, message, id, isGeneratedId, options, ctx);
|
|
410
412
|
});
|
|
411
413
|
if (options.mergePlurals) {
|
|
412
414
|
const mergedPlurals = mergeDuplicatePluralEntries(po.items, options);
|
package/dist/po-gettext.d.cts
CHANGED
|
@@ -2,8 +2,21 @@ import { CatalogFormatter } from '@lingui/conf';
|
|
|
2
2
|
import { PoFormatterOptions } from '@lingui/format-po';
|
|
3
3
|
|
|
4
4
|
type PoGettextFormatterOptions = PoFormatterOptions & {
|
|
5
|
+
/**
|
|
6
|
+
* Disable warning about unsupported `Select` feature encountered in catalogs
|
|
7
|
+
*
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
5
10
|
disableSelectWarning?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Overrides the default prefix for icu and plural comments in the final PO catalog.
|
|
13
|
+
*
|
|
14
|
+
* @default "js-lingui:"
|
|
15
|
+
*/
|
|
6
16
|
customICUPrefix?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Combine plural entries that have the same content but different variables into a single PO entry
|
|
19
|
+
*/
|
|
7
20
|
mergePlurals?: boolean;
|
|
8
21
|
};
|
|
9
22
|
declare function formatter(options?: PoGettextFormatterOptions): CatalogFormatter;
|
package/dist/po-gettext.d.mts
CHANGED
|
@@ -2,8 +2,21 @@ import { CatalogFormatter } from '@lingui/conf';
|
|
|
2
2
|
import { PoFormatterOptions } from '@lingui/format-po';
|
|
3
3
|
|
|
4
4
|
type PoGettextFormatterOptions = PoFormatterOptions & {
|
|
5
|
+
/**
|
|
6
|
+
* Disable warning about unsupported `Select` feature encountered in catalogs
|
|
7
|
+
*
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
5
10
|
disableSelectWarning?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Overrides the default prefix for icu and plural comments in the final PO catalog.
|
|
13
|
+
*
|
|
14
|
+
* @default "js-lingui:"
|
|
15
|
+
*/
|
|
6
16
|
customICUPrefix?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Combine plural entries that have the same content but different variables into a single PO entry
|
|
19
|
+
*/
|
|
7
20
|
mergePlurals?: boolean;
|
|
8
21
|
};
|
|
9
22
|
declare function formatter(options?: PoGettextFormatterOptions): CatalogFormatter;
|
package/dist/po-gettext.d.ts
CHANGED
|
@@ -2,8 +2,21 @@ import { CatalogFormatter } from '@lingui/conf';
|
|
|
2
2
|
import { PoFormatterOptions } from '@lingui/format-po';
|
|
3
3
|
|
|
4
4
|
type PoGettextFormatterOptions = PoFormatterOptions & {
|
|
5
|
+
/**
|
|
6
|
+
* Disable warning about unsupported `Select` feature encountered in catalogs
|
|
7
|
+
*
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
5
10
|
disableSelectWarning?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Overrides the default prefix for icu and plural comments in the final PO catalog.
|
|
13
|
+
*
|
|
14
|
+
* @default "js-lingui:"
|
|
15
|
+
*/
|
|
6
16
|
customICUPrefix?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Combine plural entries that have the same content but different variables into a single PO entry
|
|
19
|
+
*/
|
|
7
20
|
mergePlurals?: boolean;
|
|
8
21
|
};
|
|
9
22
|
declare function formatter(options?: PoGettextFormatterOptions): CatalogFormatter;
|
package/dist/po-gettext.mjs
CHANGED
|
@@ -83,7 +83,7 @@ const ICU_PLURAL_REGEX = /^{.*, plural, .*}$/;
|
|
|
83
83
|
const ICU_SELECT_REGEX = /^{.*, select(Ordinal)?, .*}$/;
|
|
84
84
|
const LINE_ENDINGS = /\r?\n/g;
|
|
85
85
|
const DEFAULT_CTX_PREFIX = "js-lingui:";
|
|
86
|
-
function serializePlurals(item, message, id, isGeneratedId, options) {
|
|
86
|
+
function serializePlurals(item, message, id, isGeneratedId, options, formatterCtx) {
|
|
87
87
|
const icuMessage = message.message;
|
|
88
88
|
const ctxPrefix = options.customICUPrefix || DEFAULT_CTX_PREFIX;
|
|
89
89
|
if (!icuMessage) {
|
|
@@ -124,6 +124,8 @@ function serializePlurals(item, message, id, isGeneratedId, options) {
|
|
|
124
124
|
} else {
|
|
125
125
|
item.msgstr = ast.cases.map(stringifyICUCase);
|
|
126
126
|
}
|
|
127
|
+
} else if (!isGeneratedId && (formatterCtx.locale === formatterCtx.sourceLocale || formatterCtx.locale === null)) {
|
|
128
|
+
item.msgstr = messageAst.cases.map(stringifyICUCase);
|
|
127
129
|
}
|
|
128
130
|
} catch (e) {
|
|
129
131
|
console.error(`Error parsing message ICU for key "${id}":`, e);
|
|
@@ -253,7 +255,7 @@ function serializeContextToComment(ctx) {
|
|
|
253
255
|
urlParams.set("pluralize_on", ctx.pluralizeOn.join(","));
|
|
254
256
|
}
|
|
255
257
|
urlParams.sort();
|
|
256
|
-
return urlParams.toString()
|
|
258
|
+
return urlParams.toString();
|
|
257
259
|
}
|
|
258
260
|
function getContextFromComments(extractedComments, ctxPrefix) {
|
|
259
261
|
const contextComment = extractedComments.find(
|
|
@@ -397,7 +399,7 @@ function formatter(options = {}) {
|
|
|
397
399
|
);
|
|
398
400
|
const id = isGeneratedId ? generateMessageId(item.msgid, item.msgctxt) : item.msgid;
|
|
399
401
|
const message = catalog[id];
|
|
400
|
-
return serializePlurals(item, message, id, isGeneratedId, options);
|
|
402
|
+
return serializePlurals(item, message, id, isGeneratedId, options, ctx);
|
|
401
403
|
});
|
|
402
404
|
if (options.mergePlurals) {
|
|
403
405
|
const mergedPlurals = mergeDuplicatePluralEntries(po.items, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/format-po-gettext",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "Gettext PO format with gettext-style plurals for Lingui Catalogs",
|
|
5
5
|
"main": "./dist/po-gettext.cjs",
|
|
6
6
|
"module": "./dist/po-gettext.mjs",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"dist/"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@lingui/conf": "5.
|
|
47
|
-
"@lingui/format-po": "5.
|
|
48
|
-
"@lingui/message-utils": "5.
|
|
46
|
+
"@lingui/conf": "5.8.0",
|
|
47
|
+
"@lingui/format-po": "5.8.0",
|
|
48
|
+
"@lingui/message-utils": "5.8.0",
|
|
49
49
|
"@messageformat/parser": "^5.0.0",
|
|
50
50
|
"cldr-core": "^45.0.0",
|
|
51
51
|
"node-gettext": "^3.0.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"mockdate": "^3.0.5",
|
|
58
58
|
"unbuild": "2.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "83d0513bdda9ff14003a05d376c7fedf860dd7ee"
|
|
61
61
|
}
|