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

@wordpress/i18n

Package Overview
Dependencies
Maintainers
9
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.2.0 to 3.3.0

2

build-module/index.js

@@ -155,3 +155,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";

* @param {string} format The format of the string to generate.
* @param {string[]} ...args Arguments to apply to the format.
* @param {...string} args Arguments to apply to the format.
*

@@ -158,0 +158,0 @@ * @see http://www.diveintojavascript.com/projects/javascript-sprintf

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

* @param {string} format The format of the string to generate.
* @param {string[]} ...args Arguments to apply to the format.
* @param {...string} args Arguments to apply to the format.
*

@@ -179,0 +179,0 @@ * @see http://www.diveintojavascript.com/projects/javascript-sprintf

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

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

},
"gitHead": "80d228669adadb8dfcd24b8421517fed3be2d474"
"gitHead": "1e024a20a20369af7bc9720a676fdd3837a3a105"
}
# Internationalization (i18n)
Internationalization utilities for client-side localization.
Internationalization utilities for client-side localization. See [How to Internationalize Your Plugin](https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/) for server-side documentation.
https://codex.wordpress.org/I18n_for_WordPress_Developers
## Installation

@@ -26,50 +24,131 @@

Note that you will not need to specify [domain](https://codex.wordpress.org/I18n_for_WordPress_Developers#Text_Domains) for the strings.
For a complete example, see the [Internationalization section of the Gutenberg Handbook](https://wordpress.org/gutenberg/handbook/designers-developers/developers/internationalization/).
## Build
## API
You can use the [WordPress i18n babel plugin](/packages/babel-plugin-makepot/README.md) to generate a `.pot` file containing all your localized strings.
<!-- START TOKEN(Autogenerated API docs) -->
The package also includes a `pot-to-php` script used to generate a php files containing the messages listed in a `.pot` file. This is useful to trick WordPress.org translation strings discovery since at the moment, WordPress.org is not capable of parsing strings directly from JavaScript files.
### setLocaleData
```sh
npx pot-to-php languages/myplugin.pot languages/myplugin-translations.php text-domain
```
[src/index.js#L45-L58](src/index.js#L45-L58)
## API
Merges locale data into the Tannin instance by domain. Accepts data in a
Jed-formatted JSON object shape.
`__( text: string, domain: string ): string`
**Related**
Retrieve the translation of text.
- <http://messageformat.github.io/Jed/>
See: https://developer.wordpress.org/reference/functions/__/
**Parameters**
`_x( text: string, context: string, domain: string ): string`
- **data** `?Object`: Locale data configuration.
- **domain** `?string`: Domain for which configuration applies.
### sprintf
[src/index.js#L159-L167](src/index.js#L159-L167)
Returns a formatted string. If an error occurs in applying the format, the
original format string is returned.
**Related**
- <http://www.diveintojavascript.com/projects/javascript-sprintf>
**Parameters**
- **format** `string`: The format of the string to generate.
- **args** `...string`: Arguments to apply to the format.
**Returns**
`string`: The formatted string.
### \_n
[src/index.js#L125-L127](src/index.js#L125-L127)
Translates and retrieves the singular or plural form based on the supplied
number.
**Related**
- <https://developer.wordpress.org/reference/functions/_n/>
**Parameters**
- **single** `string`: The text to be used if the number is singular.
- **plural** `string`: The text to be used if the number is plural.
- **number** `number`: The number to compare against to use either the singular or plural form.
- **domain** `?string`: Domain to retrieve the translated text.
**Returns**
`string`: The translated singular or plural form.
### \_nx
[src/index.js#L144-L146](src/index.js#L144-L146)
Translates and retrieves the singular or plural form based on the supplied
number, with gettext context.
**Related**
- <https://developer.wordpress.org/reference/functions/_nx/>
**Parameters**
- **single** `string`: The text to be used if the number is singular.
- **plural** `string`: The text to be used if the number is plural.
- **number** `number`: The number to compare against to use either the singular or plural form.
- **context** `string`: Context information for the translators.
- **domain** `?string`: Domain to retrieve the translated text.
**Returns**
`string`: The translated singular or plural form.
### \_x
[src/index.js#L107-L109](src/index.js#L107-L109)
Retrieve translated string with gettext context.
See: https://developer.wordpress.org/reference/functions/_x/
**Related**
`_n( single: string, plural: string, number: Number, domain: string ): string`
- <https://developer.wordpress.org/reference/functions/_x/>
Translates and retrieves the singular or plural form based on the supplied number.
**Parameters**
See: https://developer.wordpress.org/reference/functions/_n/
- **text** `string`: Text to translate.
- **context** `string`: Context information for the translators.
- **domain** `?string`: Domain to retrieve the translated text.
`_nx( single: string, plural: string, number: Number, context: string, domain: string ): string`
**Returns**
Translates and retrieves the singular or plural form based on the supplied number, with gettext context.
`string`: Translated context string without pipe.
See: https://developer.wordpress.org/reference/functions/_nx/
### \_\_
`sprintf( format: string, ...args: mixed[] ): string`
[src/index.js#L92-L94](src/index.js#L92-L94)
Returns a formatted string.
Retrieve the translation of text.
See: http://www.diveintojavascript.com/projects/javascript-sprintf
**Related**
`setLocaleData( data: Object, domain: string )`
- <https://developer.wordpress.org/reference/functions/__/>
Creates a new Jed instance with specified locale data configuration.
**Parameters**
- **text** `string`: Text to translate.
- **domain** `?string`: Domain to retrieve the translated text.
**Returns**
`string`: Translated text.
<!-- END TOKEN(Autogenerated API docs) -->
<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

@@ -153,3 +153,3 @@ /**

* @param {string} format The format of the string to generate.
* @param {string[]} ...args Arguments to apply to the format.
* @param {...string} args Arguments to apply to the format.
*

@@ -156,0 +156,0 @@ * @see http://www.diveintojavascript.com/projects/javascript-sprintf

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