PHPackages                             automattic/babel-plugin-replace-textdomain - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. automattic/babel-plugin-replace-textdomain

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

automattic/babel-plugin-replace-textdomain
==========================================

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

v1.0.57(6d ago)4381GPL-2.0-or-laterJavaScriptCI failing

Since Dec 14Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/Automattic/babel-plugin-replace-textdomain)[ Packagist](https://packagist.org/packages/automattic/babel-plugin-replace-textdomain)[ RSS](/packages/automattic-babel-plugin-replace-textdomain/feed)WikiDiscussions trunk Synced today

READMEChangelogDependencies (2)Versions (62)Used By (0)

babel-plugin-replace-textdomain
===============================

[](#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
------------

[](#installation)

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

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

```

Usage
-----

[](#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](https://www.npmjs.com/package/@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
--------

[](#security)

Need to report a security vulnerability? Go to  or directly to our security bug bounty site .

License
-------

[](#license)

babel-plugin-replace-textdomain is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt)

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance93

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 52.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~27 days

Recently: every ~42 days

Total

59

Last Release

6d ago

Major Versions

v0.1.0 → v1.0.02021-12-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c5869ecbb8e0eac7e8b8e0f3cf7bdd8d5fcdc4abc10a72281872c53f8639d44?d=identicon)[automattic](/maintainers/automattic)

![](https://www.gravatar.com/avatar/11609890f6e7a840715f4cfc9622d77ea64b7dfc024df5643fbf8471a18c00f3?d=identicon)[kraft](/maintainers/kraft)

![](https://www.gravatar.com/avatar/5326730499ec14e274f51b9bcc39db6aac0fb38b33849715aae0e2587a2b93df?d=identicon)[jeherve](/maintainers/jeherve)

![](https://www.gravatar.com/avatar/6e220e167e341c28b1aa10bf0bb0374999068329f8683d3187ee3cf6749b8837?d=identicon)[dereksmart](/maintainers/dereksmart)

---

Top Contributors

[![anomiex](https://avatars.githubusercontent.com/u/1030580?v=4)](https://github.com/anomiex "anomiex (127 commits)")[![tbradsha](https://avatars.githubusercontent.com/u/32492176?v=4)](https://github.com/tbradsha "tbradsha (28 commits)")[![samiff](https://avatars.githubusercontent.com/u/15803018?v=4)](https://github.com/samiff "samiff (13 commits)")[![jeherve](https://avatars.githubusercontent.com/u/426388?v=4)](https://github.com/jeherve "jeherve (11 commits)")[![zinigor](https://avatars.githubusercontent.com/u/374293?v=4)](https://github.com/zinigor "zinigor (10 commits)")[![kraftbj](https://avatars.githubusercontent.com/u/88897?v=4)](https://github.com/kraftbj "kraftbj (7 commits)")[![coder-karen](https://avatars.githubusercontent.com/u/16754605?v=4)](https://github.com/coder-karen "coder-karen (6 commits)")[![sdixon194](https://avatars.githubusercontent.com/u/33553323?v=4)](https://github.com/sdixon194 "sdixon194 (5 commits)")[![gmjuhasz](https://avatars.githubusercontent.com/u/36671565?v=4)](https://github.com/gmjuhasz "gmjuhasz (4 commits)")[![ice9js](https://avatars.githubusercontent.com/u/8056203?v=4)](https://github.com/ice9js "ice9js (3 commits)")[![haqadn](https://avatars.githubusercontent.com/u/3737780?v=4)](https://github.com/haqadn "haqadn (2 commits)")[![adimoldovan](https://avatars.githubusercontent.com/u/3854374?v=4)](https://github.com/adimoldovan "adimoldovan (2 commits)")[![bindlegirl](https://avatars.githubusercontent.com/u/1242807?v=4)](https://github.com/bindlegirl "bindlegirl (2 commits)")[![CGastrell](https://avatars.githubusercontent.com/u/157240?v=4)](https://github.com/CGastrell "CGastrell (2 commits)")[![chihsuan](https://avatars.githubusercontent.com/u/4344253?v=4)](https://github.com/chihsuan "chihsuan (2 commits)")[![adamwoodnz](https://avatars.githubusercontent.com/u/1017872?v=4)](https://github.com/adamwoodnz "adamwoodnz (2 commits)")[![kangzj](https://avatars.githubusercontent.com/u/1425433?v=4)](https://github.com/kangzj "kangzj (2 commits)")[![manzoorwanijk](https://avatars.githubusercontent.com/u/18226415?v=4)](https://github.com/manzoorwanijk "manzoorwanijk (2 commits)")[![nunyvega](https://avatars.githubusercontent.com/u/16329583?v=4)](https://github.com/nunyvega "nunyvega (2 commits)")[![ArSn](https://avatars.githubusercontent.com/u/2803693?v=4)](https://github.com/ArSn "ArSn (1 commits)")

---

Tags

babelbabel-plugingettext

### Embed Badge

![Health badge](/badges/automattic-babel-plugin-replace-textdomain/health.svg)

```
[![Health](https://phpackages.com/badges/automattic-babel-plugin-replace-textdomain/health.svg)](https://phpackages.com/packages/automattic-babel-plugin-replace-textdomain)
```

###  Alternatives

[nativephp/electron

Electron wrapper for the NativePHP framework.

519114.4k8](/packages/nativephp-electron)[kadet/keylighter

Yet another syntax highlighter for PHP

333.2k1](/packages/kadet-keylighter)[code16/formoj

Customizable form renderer

332.6k](/packages/code16-formoj)[nullthoughts/laravel-data-sync

Laravel utility to keep records synced between environments through source control

331.4k](/packages/nullthoughts-laravel-data-sync)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
