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

    Keywords

    none

    Install

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

    DownloadsWeekly Downloads

    547

    Version

    1.0.0

    License

    GPL-2.0-or-later

    Unpacked Size

    3.21 kB

    Total Files

    5

    Last publish

    Collaborators

    • t2dw4t
    • ehg_
    • wwa
    • sirreal
    • elazzabi
    • royho
    • obliviousharmony
    • luismulinari
    • macbre
    • quasistar
    • mjangda
    • matticbot
    • djalmaaraujo
    • brunobasto
    • a8c
    • nickdaugherty
    • blowery
    • noahtallen
    • hanifn
    • sgomes
    • tyxla
    • bms
    • rrinat
    • netsuso
    • saroshaga
    • parkcityj
    • nejclovrencic
    • sirbrillig
    • samiff
    • chriszarate
    • rogertheriault
    • robersongomes
    • johngodley