next-intl 4.11.1 → 4.12.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/cjs/development/{JSONCodec-B-lAnRTg.cjs → JSONCodec-CzA8ubPy.cjs} +4 -2
- package/dist/cjs/development/{POCodec-0XdsL-1F.cjs → POCodec-CWGHK-Gp.cjs} +16 -10
- package/dist/cjs/development/{plugin-0S9vVrVM.cjs → plugin-DlFYUFWh.cjs} +281 -150
- package/dist/cjs/development/plugin.cjs +1 -1
- package/dist/esm/development/extractor/catalog/CatalogManager.js +146 -95
- package/dist/esm/development/extractor/extractMessages.js +9 -2
- package/dist/esm/development/extractor/format/codecs/JSONCodec.js +3 -1
- package/dist/esm/development/extractor/format/codecs/POCodec.js +15 -9
- package/dist/esm/development/extractor/normalizeExtractorConfig.js +70 -0
- package/dist/esm/development/extractor/source/SourceFileWatcher.js +1 -1
- package/dist/esm/development/extractor/utils.js +29 -5
- package/dist/esm/development/middleware/middleware.js +7 -14
- package/dist/esm/development/plugin/createNextIntlPlugin.js +13 -2
- package/dist/esm/development/plugin/extractor/initExtractionCompiler.js +3 -8
- package/dist/esm/development/plugin/getNextConfig.js +21 -34
- package/dist/esm/development/server/react-server/getServerExtractor.js +3 -3
- package/dist/esm/production/extractor/catalog/CatalogManager.js +1 -1
- package/dist/esm/production/extractor/extractMessages.js +1 -1
- package/dist/esm/production/extractor/format/codecs/JSONCodec.js +1 -1
- package/dist/esm/production/extractor/format/codecs/POCodec.js +1 -1
- package/dist/esm/production/extractor/normalizeExtractorConfig.js +1 -0
- package/dist/esm/production/extractor/source/SourceFileWatcher.js +1 -1
- package/dist/esm/production/extractor/utils.js +1 -1
- package/dist/esm/production/middleware/middleware.js +1 -1
- package/dist/esm/production/plugin/createNextIntlPlugin.js +1 -1
- package/dist/esm/production/plugin/extractor/initExtractionCompiler.js +1 -1
- package/dist/esm/production/plugin/getNextConfig.js +1 -1
- package/dist/esm/production/server/react-server/getServerExtractor.js +1 -1
- package/dist/types/extractor/ExtractionCompiler.d.ts +2 -1
- package/dist/types/extractor/catalog/CatalogLocales.d.ts +2 -2
- package/dist/types/extractor/catalog/CatalogManager.d.ts +27 -10
- package/dist/types/extractor/extractMessages.d.ts +2 -2
- package/dist/types/extractor/extractor/MessageExtractor.d.ts +2 -6
- package/dist/types/extractor/normalizeExtractorConfig.d.ts +5 -0
- package/dist/types/extractor/types.d.ts +62 -11
- package/dist/types/extractor/utils.d.ts +2 -1
- package/dist/types/plugin/extractor/initExtractionCompiler.d.ts +2 -2
- package/dist/types/plugin/getNextConfig.d.ts +2 -1
- package/dist/types/plugin/types.d.ts +10 -14
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var plugin = require('./plugin-
|
|
3
|
+
var plugin = require('./plugin-DlFYUFWh.cjs');
|
|
4
4
|
var ExtractorCodec = require('./ExtractorCodec-D9Tw618d.cjs');
|
|
5
5
|
require('fs/promises');
|
|
6
6
|
require('path');
|
|
@@ -16,7 +16,9 @@ var JSONCodec = ExtractorCodec.defineCodec(() => ({
|
|
|
16
16
|
traverseMessages(json, (message, id) => {
|
|
17
17
|
messages.push({
|
|
18
18
|
id,
|
|
19
|
-
message
|
|
19
|
+
message,
|
|
20
|
+
references: [],
|
|
21
|
+
description: []
|
|
20
22
|
});
|
|
21
23
|
});
|
|
22
24
|
return messages;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var POParser = require('po-parser');
|
|
4
|
-
var plugin = require('./plugin-
|
|
4
|
+
var plugin = require('./plugin-DlFYUFWh.cjs');
|
|
5
5
|
var ExtractorCodec = require('./ExtractorCodec-D9Tw618d.cjs');
|
|
6
6
|
require('fs/promises');
|
|
7
7
|
require('path');
|
|
@@ -44,41 +44,47 @@ var POCodec = ExtractorCodec.defineCodec(() => {
|
|
|
44
44
|
msgctxt,
|
|
45
45
|
msgid,
|
|
46
46
|
msgstr,
|
|
47
|
+
references,
|
|
47
48
|
...rest
|
|
48
49
|
} = msg;
|
|
49
|
-
if (extractedComments && extractedComments.length > 1) {
|
|
50
|
-
throw new Error(`Multiple extracted comments are not supported. Found ${extractedComments.length} comments for msgid "${msgid}".`);
|
|
51
|
-
}
|
|
52
50
|
return {
|
|
53
51
|
...rest,
|
|
54
52
|
id: msgctxt ? [msgctxt, msgid].join(NAMESPACE_SEPARATOR) : msgid,
|
|
55
53
|
message: msgstr,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})
|
|
54
|
+
description: extractedComments ?? [],
|
|
55
|
+
references: references ?? []
|
|
59
56
|
};
|
|
60
57
|
});
|
|
61
58
|
},
|
|
62
59
|
encode(messages, context) {
|
|
63
60
|
const encodedMessages = plugin.getSortedMessages(messages).map(msg => {
|
|
64
61
|
const {
|
|
65
|
-
description,
|
|
62
|
+
description = [],
|
|
66
63
|
id,
|
|
67
64
|
message,
|
|
65
|
+
references,
|
|
68
66
|
...rest
|
|
69
67
|
} = msg;
|
|
70
68
|
const lastDotIndex = id.lastIndexOf(NAMESPACE_SEPARATOR);
|
|
71
69
|
const hasNamespace = id.includes(NAMESPACE_SEPARATOR);
|
|
72
70
|
const msgid = hasNamespace ? id.slice(lastDotIndex + NAMESPACE_SEPARATOR.length) : id;
|
|
71
|
+
|
|
72
|
+
// Path-only refs (no `:line`), unique paths
|
|
73
|
+
const pathOnlyRefs = [...new Set(references.map(ref => ref.path))].map(path => ({
|
|
74
|
+
path
|
|
75
|
+
}));
|
|
73
76
|
return {
|
|
74
77
|
msgid,
|
|
75
78
|
msgstr: message,
|
|
76
|
-
...(description && {
|
|
77
|
-
extractedComments:
|
|
79
|
+
...(description.length > 0 && {
|
|
80
|
+
extractedComments: description
|
|
78
81
|
}),
|
|
79
82
|
...(hasNamespace && {
|
|
80
83
|
msgctxt: id.slice(0, lastDotIndex)
|
|
81
84
|
}),
|
|
85
|
+
...(pathOnlyRefs.length > 0 && {
|
|
86
|
+
references: pathOnlyRefs
|
|
87
|
+
}),
|
|
82
88
|
...rest
|
|
83
89
|
};
|
|
84
90
|
});
|