@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.
Files changed (2) hide show
  1. package/index.js +40 -45
  2. 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, reduce, isEqual, merge, isEmpty } = require( 'lodash' );
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
- files,
329
- ( memo, file ) => {
330
- for ( const context in strings[ file ] ) {
331
- // Within the same file, sort translations by line.
332
- const sortedTranslations = sortByReference(
333
- Object.values( strings[ file ][ context ] )
334
- );
335
-
336
- sortedTranslations.forEach( ( translation ) => {
337
- const { msgctxt = '', msgid } = translation;
338
- if ( ! memo.hasOwnProperty( msgctxt ) ) {
339
- memo[ msgctxt ] = {};
340
- }
341
-
342
- // Merge references if translation already exists.
343
- if (
344
- isSameTranslation(
345
- translation,
346
- memo[ msgctxt ][ msgid ]
347
- )
348
- ) {
349
- translation.comments.reference = [
350
- ...new Set(
351
- [
352
- memo[ msgctxt ][ msgid ]
353
- .comments.reference,
354
- translation.comments
355
- .reference,
356
- ]
357
- .join( '\n' )
358
- .split( '\n' )
359
- ),
360
- ].join( '\n' );
361
- }
362
-
363
- memo[ msgctxt ][ msgid ] = translation;
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.5.0",
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": "511f4cc1f0138641bc4394bc1cf36e833109c791"
40
+ "gitHead": "7ac04f446242452d3cb24372f9ca58f0cae97715"
41
41
  }