Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/i18n

Package Overview
Dependencies
Maintainers
14
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/i18n - npm Package Compare versions

Comparing version 3.8.0 to 3.9.0

2

benchmark/index.js
const Benchmark = require( 'benchmark' );
const { __ } = require( '../' );
const suite = new Benchmark.Suite;
const suite = new Benchmark.Suite();

@@ -6,0 +6,0 @@ suite

@@ -1,3 +0,7 @@

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**

@@ -56,6 +60,6 @@ * External dependencies

var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
i18n.data[domain] = _objectSpread({}, DEFAULT_LOCALE_DATA, i18n.data[domain], data); // Populate default domain configuration (supported locale date which omits
i18n.data[domain] = _objectSpread({}, DEFAULT_LOCALE_DATA, {}, i18n.data[domain], {}, data); // Populate default domain configuration (supported locale date which omits
// a plural forms expression).
i18n.data[domain][''] = _objectSpread({}, DEFAULT_LOCALE_DATA[''], i18n.data[domain]['']);
i18n.data[domain][''] = _objectSpread({}, DEFAULT_LOCALE_DATA[''], {}, i18n.data[domain]['']);
}

@@ -62,0 +66,0 @@ /**

@@ -15,3 +15,3 @@ "use strict";

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -24,6 +24,6 @@ var _tannin = _interopRequireDefault(require("tannin"));

/**
* External dependencies
*/
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**

@@ -75,6 +75,6 @@ * @typedef {{[key: string]: any}} LocaleData

var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
i18n.data[domain] = (0, _objectSpread2.default)({}, DEFAULT_LOCALE_DATA, i18n.data[domain], data); // Populate default domain configuration (supported locale date which omits
i18n.data[domain] = _objectSpread({}, DEFAULT_LOCALE_DATA, {}, i18n.data[domain], {}, data); // Populate default domain configuration (supported locale date which omits
// a plural forms expression).
i18n.data[domain][''] = (0, _objectSpread2.default)({}, DEFAULT_LOCALE_DATA[''], i18n.data[domain]['']);
i18n.data[domain][''] = _objectSpread({}, DEFAULT_LOCALE_DATA[''], {}, i18n.data[domain]['']);
}

@@ -81,0 +81,0 @@ /**

{
"name": "@wordpress/i18n",
"version": "3.8.0",
"version": "3.9.0",
"description": "WordPress internationalization (i18n) library.",

@@ -27,3 +27,3 @@ "author": "The WordPress Contributors",

"dependencies": {
"@babel/runtime": "^7.4.4",
"@babel/runtime": "^7.8.3",
"gettext-parser": "^1.3.1",

@@ -38,3 +38,3 @@ "lodash": "^4.17.15",

},
"gitHead": "3e867dd7c6560e4b2cb9a59cc02856e055be6142"
"gitHead": "41fc84af285da696c65c235331ee245dfe23971d"
}

@@ -51,7 +51,11 @@ /**

it( 'use the plural form', () => {
expect( _n( '%d banana', '%d bananas', 3, 'test_domain' ) ).toBe( '%d bananes' );
expect( _n( '%d banana', '%d bananas', 3, 'test_domain' ) ).toBe(
'%d bananes'
);
} );
it( 'use the singular form', () => {
expect( _n( '%d banana', '%d bananas', 1, 'test_domain' ) ).toBe( '%d banane' );
expect( _n( '%d banana', '%d bananas', 1, 'test_domain' ) ).toBe(
'%d banane'
);
} );

@@ -62,7 +66,11 @@ } );

it( 'use the plural form', () => {
expect( _nx( '%d apple', '%d apples', 3, 'fruit', 'test_domain' ) ).toBe( '%d pommes' );
expect(
_nx( '%d apple', '%d apples', 3, 'fruit', 'test_domain' )
).toBe( '%d pommes' );
} );
it( 'use the singular form', () => {
expect( _nx( '%d apple', '%d apples', 1, 'fruit', 'test_domain' ) ).toBe( '%d pomme' );
expect(
_nx( '%d apple', '%d apples', 1, 'fruit', 'test_domain' )
).toBe( '%d pomme' );
} );

@@ -94,12 +102,17 @@ } );

it( 'supports omitted plural forms expression', () => {
setLocaleData( {
'': {
domain: 'test_domain2',
lang: 'fr',
setLocaleData(
{
'': {
domain: 'test_domain2',
lang: 'fr',
},
'%d banana': [ '%d banane', '%d bananes' ],
},
'test_domain2'
);
'%d banana': [ '%d banane', '%d bananes' ],
}, 'test_domain2' );
expect( _n( '%d banana', '%d bananes', 2, 'test_domain2' ) ).toBe( '%d bananes' );
expect( _n( '%d banana', '%d bananes', 2, 'test_domain2' ) ).toBe(
'%d bananes'
);
} );

@@ -113,3 +126,5 @@

it( 'new translation available.', () => {
expect( __( 'cheeseburger', 'test_domain' ) ).toBe( 'hamburger au fromage' );
expect( __( 'cheeseburger', 'test_domain' ) ).toBe(
'hamburger au fromage'
);
} );

@@ -120,11 +135,17 @@ } );

it( 'existing plural form still works', () => {
expect( _n( '%d banana', '%d bananas', 3, 'test_domain' ) ).toBe( '%d bananes' );
expect(
_n( '%d banana', '%d bananas', 3, 'test_domain' )
).toBe( '%d bananes' );
} );
it( 'new singular form was added', () => {
expect( _n( '%d cat', '%d cats', 1, 'test_domain' ) ).toBe( '%d chat' );
expect( _n( '%d cat', '%d cats', 1, 'test_domain' ) ).toBe(
'%d chat'
);
} );
it( 'new plural form was added', () => {
expect( _n( '%d cat', '%d cats', 3, 'test_domain' ) ).toBe( '%d chats' );
expect( _n( '%d cat', '%d cats', 3, 'test_domain' ) ).toBe(
'%d chats'
);
} );

@@ -131,0 +152,0 @@ } );

@@ -10,12 +10,13 @@ #!/usr/bin/env node

const fileHeader = [
'<?php',
'/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */',
'$generated_i18n_strings = array(',
].join( NEWLINE ) + NEWLINE;
const fileHeader =
[
'<?php',
'/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */',
'$generated_i18n_strings = array(',
].join( NEWLINE ) + NEWLINE;
const fileFooter = NEWLINE + [
');',
'/* THIS IS THE END OF THE GENERATED FILE */',
].join( NEWLINE ) + NEWLINE;
const fileFooter =
NEWLINE +
[ ');', '/* THIS IS THE END OF THE GENERATED FILE */' ].join( NEWLINE ) +
NEWLINE;

@@ -29,3 +30,3 @@ /**

function escapeSingleQuotes( input ) {
return input.replace( /'/g, '\\\'' );
return input.replace( /'/g, "\\'" );
}

@@ -51,3 +52,5 @@

// All references are split by newlines, add a // Reference prefix to make them tidy.
php += TAB + '// Reference: ' +
php +=
TAB +
'// Reference: ' +
comments.reference

@@ -69,3 +72,4 @@ .split( NEWLINE )

if ( ! isEmpty( comments.extracted ) ) {
php += TAB + `/* translators: ${ comments.extracted } */${ NEWLINE }`;
php +=
TAB + `/* translators: ${ comments.extracted } */${ NEWLINE }`;
}

@@ -81,3 +85,5 @@ }

} else {
php += TAB + `_x( '${ original }', '${ translation.msgctxt }', '${ textdomain }' )`;
php +=
TAB +
`_x( '${ original }', '${ translation.msgctxt }', '${ textdomain }' )`;
}

@@ -88,5 +94,9 @@ } else {

if ( isEmpty( context ) ) {
php += TAB + `_n_noop( '${ original }', '${ plural }', '${ textdomain }' )`;
php +=
TAB +
`_n_noop( '${ original }', '${ plural }', '${ textdomain }' )`;
} else {
php += TAB + `_nx_noop( '${ original }', '${ plural }', '${ translation.msgctxt }', '${ textdomain }' )`;
php +=
TAB +
`_nx_noop( '${ original }', '${ plural }', '${ translation.msgctxt }', '${ textdomain }' )`;
}

@@ -109,3 +119,9 @@ }

const newOutput = Object.values( translations )
.map( ( translation ) => convertTranslationToPHP( translation, options.textdomain, context ) )
.map( ( translation ) =>
convertTranslationToPHP(
translation,
options.textdomain,
context
)
)
.filter( ( php ) => php !== '' );

@@ -116,3 +132,4 @@

const fileOutput = fileHeader + output.join( ',' + NEWLINE + NEWLINE ) + fileFooter;
const fileOutput =
fileHeader + output.join( ',' + NEWLINE + NEWLINE ) + fileFooter;

@@ -124,8 +141,4 @@ fs.writeFileSync( phpFile, fileOutput );

convertPOTToPHP(
args[ 0 ],
args[ 1 ],
{
textdomain: args[ 2 ],
}
);
convertPOTToPHP( args[ 0 ], args[ 1 ], {
textdomain: args[ 2 ],
} );

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc