@automattic/babel-plugin-replace-textdomain

1.0.39 • Public • Published

babel-plugin-replace-textdomain

A Babel plugin to replace the textdomain in gettext-style function calls.

This may be useful when using node modules for code-sharing among multiple applications (e.g. WordPress plugins), so each application's bundle uses a consistent textdomain throughout.

Installation

Generally you'll install this via your package manager, e.g.

npm install --save-dev @automattic/babel-plugin-replace-textdomain

Usage

In your Babel config, you might include the plugin something like this:

{
	"plugins": [
		[ "@automattic/babel-plugin-replace-textdomain", { "textdomain": "new-domain" } ]
	]
}

Plugin options are:

  • textdomain: Specify the replacement text domain. The value may be a string, which will replace all domains; an object, to map specific domains (leaving any others untouched); or a function, which will be passed the existing domain (empty string if the domain is missing entirely) and is expected to return the new domain (or null).

  • functions: Specify the functions that take domain arguments. This is an object mapping function names to the (zero-based) index of the domain argument.

    The default function list handles the __, _x, _n, and _nx functions provided by @wordpress/i18n. This list may be accessed as require( '@automattic/babel-plugin-replace-textdomain' ).defaultFunctions.

To report instances of the specified i18n functions called without a domain or with an improper value for the domain, set the DEBUG environment variable to include @automattic/babel-plugin-replace-textdomain.

Security

Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.

License

babel-plugin-replace-textdomain is licensed under GNU General Public License v2 (or later)

Readme

Keywords

none

Package Sidebar

Install

npm i @automattic/babel-plugin-replace-textdomain

Weekly Downloads

168

Version

1.0.39

License

GPL-2.0-or-later

Unpacked Size

34.8 kB

Total Files

6

Last publish

Collaborators

  • natalia.vidal
  • mehmoodak
  • mattwest-a8c
  • artpi
  • kthai15
  • dsmartg
  • pottedmeat
  • ianramosa8c
  • dilirity
  • arthur791004
  • mrmurphy
  • alshakero
  • pyronaur
  • imranh920
  • gmjuhasz
  • rcarvalho
  • briowill
  • bgrgicak
  • dhenridev
  • daledupreez-a8c
  • jeherve
  • yuliyan
  • micbosia8c
  • jeremy.yip
  • wpvip-bot
  • etobiesen
  • kzoschke
  • brunobasto
  • kat3samsin
  • fmfernandes
  • newspack
  • robertsreberski_a8c
  • msurdi-a8c
  • chihsuan
  • manzoorwanijk
  • rjchow
  • andrea-sdl
  • scjr
  • spsiddarthan
  • t2dw4t
  • ehg_
  • wwa
  • sirreal
  • elazzabi
  • royho
  • luismulinari
  • macbre
  • mjangda
  • matticbot
  • a8c
  • blowery
  • sgomes
  • tyxla
  • saroshaga
  • nejclovrencic
  • sirbrillig
  • chriszarate
  • robersongomes
  • johngodley