![New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions](https://cdn.sanity.io/images/cgdhsj6q/production/86e6ebdea652d20da070ebbda20134b839972db7-1024x1024.webp?w=800&fit=max&auto=format)
Security News
New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
@wordpress/i18n
Advanced tools
Readme
Internationalization utilities for client-side localization.
https://codex.wordpress.org/I18n_for_WordPress_Developers
Install the module:
npm install @wordpress/i18n --save
This package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using core-js or @babel/polyfill will add support for these methods. Learn more about it in Babel docs.
import { sprintf, _n } from '@wordpress/i18n';
sprintf( _n( '%d hat', '%d hats', 4, 'text-domain' ), 4 );
// 4 hats
Note that you will not need to specify domain for the strings.
You can use the WordPress i18n babel plugin to generate a .pot
file containing all your localized strings.
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.
npx pot-to-php languages/myplugin.pot languages/myplugin-translations.php text-domain
__( text: string, domain: string ): string
Retrieve the translation of text.
See: https://developer.wordpress.org/reference/functions/__/
_x( text: string, context: string, domain: string ): string
Retrieve translated string with gettext context.
See: https://developer.wordpress.org/reference/functions/_x/
_n( single: string, plural: string, number: Number, domain: string ): string
Translates and retrieves the singular or plural form based on the supplied number.
See: https://developer.wordpress.org/reference/functions/_n/
_nx( single: string, plural: string, number: Number, context: string, domain: string ): string
Translates and retrieves the singular or plural form based on the supplied number, with gettext context.
See: https://developer.wordpress.org/reference/functions/_nx/
sprintf( format: string, ...args: mixed[] ): string
Returns a formatted string.
See: http://www.diveintojavascript.com/projects/javascript-sprintf
setLocaleData( data: Object, domain: string )
Creates a new Jed instance with specified locale data configuration.
FAQs
WordPress internationalization (i18n) library.
The npm package @wordpress/i18n receives a total of 123,595 weekly downloads. As such, @wordpress/i18n popularity was classified as popular.
We found that @wordpress/i18n demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 24 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
Security News
Results from the 2023 State of JavaScript Survey highlight key trends, including Vite's dominance, rising TypeScript adoption, and the enduring popularity of React. Discover more insights on developer preferences and technology usage.
Security News
The US Justice Department has penalized two consulting firms $11.3 million for failing to meet cybersecurity requirements on federally funded projects, emphasizing strict enforcement to protect sensitive government data.