@wordpress/babel-plugin-makepot 5.5.0 → 5.6.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/index.js +40 -45
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
const { po } = require( 'gettext-parser' );
|
|
36
|
-
const { pick,
|
|
36
|
+
const { pick, isEqual, merge, isEmpty } = require( 'lodash' );
|
|
37
37
|
const { relative, sep } = require( 'path' );
|
|
38
38
|
const { writeFileSync } = require( 'fs' );
|
|
39
39
|
|
|
@@ -324,50 +324,45 @@ module.exports = () => {
|
|
|
324
324
|
const files = Object.keys( strings ).sort();
|
|
325
325
|
|
|
326
326
|
// Combine translations from each file grouped by context.
|
|
327
|
-
const translations = reduce(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
return memo;
|
|
368
|
-
},
|
|
369
|
-
{}
|
|
370
|
-
);
|
|
327
|
+
const translations = files.reduce( ( memo, file ) => {
|
|
328
|
+
for ( const context in strings[ file ] ) {
|
|
329
|
+
// Within the same file, sort translations by line.
|
|
330
|
+
const sortedTranslations = sortByReference(
|
|
331
|
+
Object.values( strings[ file ][ context ] )
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
sortedTranslations.forEach( ( translation ) => {
|
|
335
|
+
const { msgctxt = '', msgid } = translation;
|
|
336
|
+
if ( ! memo.hasOwnProperty( msgctxt ) ) {
|
|
337
|
+
memo[ msgctxt ] = {};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Merge references if translation already exists.
|
|
341
|
+
if (
|
|
342
|
+
isSameTranslation(
|
|
343
|
+
translation,
|
|
344
|
+
memo[ msgctxt ][ msgid ]
|
|
345
|
+
)
|
|
346
|
+
) {
|
|
347
|
+
translation.comments.reference = [
|
|
348
|
+
...new Set(
|
|
349
|
+
[
|
|
350
|
+
memo[ msgctxt ][ msgid ]
|
|
351
|
+
.comments.reference,
|
|
352
|
+
translation.comments.reference,
|
|
353
|
+
]
|
|
354
|
+
.join( '\n' )
|
|
355
|
+
.split( '\n' )
|
|
356
|
+
),
|
|
357
|
+
].join( '\n' );
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
memo[ msgctxt ][ msgid ] = translation;
|
|
361
|
+
} );
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return memo;
|
|
365
|
+
}, {} );
|
|
371
366
|
|
|
372
367
|
// Merge translations from individual files into headers
|
|
373
368
|
const data = merge( {}, baseData, { translations } );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/babel-plugin-makepot",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "WordPress Babel internationalization (i18n) plugin.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "7ac04f446242452d3cb24372f9ca58f0cae97715"
|
|
41
41
|
}
|