automattic / babel-plugin-replace-textdomain
A Babel plugin to replace the textdomain in gettext-style function calls.
Installs: 28
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 5
Forks: 1
Language:JavaScript
Requires (Dev)
- automattic/jetpack-changelogger: ^5.1.0
- dev-trunk
- v1.0.42
- v1.0.41
- v1.0.40
- v1.0.39
- v1.0.38
- v1.0.37
- v1.0.36
- v1.0.35
- v1.0.34
- v1.0.33
- v1.0.32
- v1.0.31
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.1.0
- dev-prerelease
- dev-fix/slack-workflow-branch-detection
This package is auto-updated.
Last update: 2024-12-20 05:32:43 UTC
README
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 asrequire( '@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)