@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.

Readme

Keywords

none

Package Sidebar

Install

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

Weekly Downloads

834

Version

1.0.0

License

GPL-2.0-or-later

Unpacked Size

3.21 kB

Total Files

5

Last publish

Collaborators

  • 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