@automattic/babel-plugin-preserve-i18n

1.0.0 • Public • Published

Babel plugin optimize i18n

Babel plugin that transforms this:

import { __, _x } from '@wordpress/i18n';

__( 'Hello' );
_x( 'World' );

to this:

import { __ as alias__, _x as alias_x } from '@wordpress/i18n';
const __ = alias__;
const _x = alias_x;

__( 'Hello' );
_x( 'World' );

Inspired by babel-plugin-optimize-react that does similar transforms for React imports.

The transform ensures that the __('Hello') syntax remains intact in the output bundle (and even after minification if Terser uses the mangle.reserved option) and can be extracted by WP i18n tools.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    673
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    673

Package Sidebar

Install

npm i @automattic/babel-plugin-preserve-i18n

Weekly Downloads

673

Version

1.0.0

License

GPL-2.0-or-later

Unpacked Size

3.21 kB

Total Files

5

Last publish

Collaborators

  • porada
  • 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
  • noahtallen
  • hanifn
  • sgomes
  • tyxla
  • saroshaga
  • parkcityj
  • nejclovrencic
  • sirbrillig
  • chriszarate
  • robersongomes
  • johngodley