diff --git a/package-lock.json b/package-lock.json index a045a86cd5b49e..96b15cb29fbe14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17454,7 +17454,6 @@ "@babel/runtime": "^7.16.0", "@wordpress/hooks": "file:packages/hooks", "gettext-parser": "^1.3.1", - "lodash": "^4.17.21", "memize": "^1.1.0", "sprintf-js": "^1.1.1", "tannin": "^1.2.0" diff --git a/packages/i18n/package.json b/packages/i18n/package.json index cb7bb9d4002700..25d00e177c68ec 100644 --- a/packages/i18n/package.json +++ b/packages/i18n/package.json @@ -32,7 +32,6 @@ "@babel/runtime": "^7.16.0", "@wordpress/hooks": "file:../hooks", "gettext-parser": "^1.3.1", - "lodash": "^4.17.21", "memize": "^1.1.0", "sprintf-js": "^1.1.1", "tannin": "^1.2.0" diff --git a/packages/i18n/tools/pot-to-php.js b/packages/i18n/tools/pot-to-php.js index 78d52d0b54cec5..1f371b539ae9c4 100755 --- a/packages/i18n/tools/pot-to-php.js +++ b/packages/i18n/tools/pot-to-php.js @@ -4,7 +4,6 @@ * External dependencies */ const gettextParser = require( 'gettext-parser' ); -const { isEmpty } = require( 'lodash' ); const fs = require( 'fs' ); const TAB = '\t'; @@ -47,8 +46,8 @@ function convertTranslationToPHP( translation, textdomain, context = '' ) { let original = translation.msgid; const comments = translation.comments; - if ( ! isEmpty( comments ) ) { - if ( ! isEmpty( comments.reference ) ) { + if ( Object.values( comments ).length ) { + if ( comments.reference ) { // All references are split by newlines, add a // Reference prefix to make them tidy. php += TAB + @@ -59,7 +58,7 @@ function convertTranslationToPHP( translation, textdomain, context = '' ) { NEWLINE; } - if ( ! isEmpty( comments.translator ) ) { + if ( comments.translator ) { // All extracted comments are split by newlines, add a tab to line them up nicely. const translator = comments.translator .split( NEWLINE ) @@ -68,7 +67,7 @@ function convertTranslationToPHP( translation, textdomain, context = '' ) { php += TAB + `/* ${ translator } */${ NEWLINE }`; } - if ( ! isEmpty( comments.extracted ) ) { + if ( comments.extracted ) { php += TAB + `/* translators: ${ comments.extracted } */${ NEWLINE }`; } @@ -77,8 +76,8 @@ function convertTranslationToPHP( translation, textdomain, context = '' ) { if ( '' !== original ) { original = escapeSingleQuotes( original ); - if ( isEmpty( translation.msgid_plural ) ) { - if ( isEmpty( context ) ) { + if ( ! translation.msgid_plural ) { + if ( ! context ) { php += TAB + `__( '${ original }', '${ textdomain }' )`; } else { php += @@ -88,7 +87,7 @@ function convertTranslationToPHP( translation, textdomain, context = '' ) { } else { const plural = escapeSingleQuotes( translation.msgid_plural ); - if ( isEmpty( context ) ) { + if ( ! context ) { php += TAB + `_n_noop( '${ original }', '${ plural }', '${ textdomain }' )`;