1.0.1 • Published 4 years ago

babel-plugin-secullum-i18n v1.0.1

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

babel-plugin-secullum-i18n

npm npm

Install

yarn add babel-plugin-secullum-i18n --dev

Usage

Via webpack config

module: {
  rules: [
    {
      test: /\.js$/,
      exclude: /node_modules/,
      use: {
        loader: "babel-loader",
        options: {
          plugins: [
            [
              "babel-plugin-secullum-i18n",
              {
                expressionsPath: "./sec-i18n.config.json",
                translateFunction: "traduzir",
              },
            ],
          ],
        },
      },
    },
  ];
}

Via babel.config.js

module.exports = (api) => ({
  plugins: [
    [
      "babel-plugin-secullum-i18n",
      {
        expressionsPath: "./sec-i18n.config.json",
        translateFunction: "translate",
      },
    ],
  ],
});

Via config-overrides.js

module.exports = function override(config, env) {
  config.module.rules[2].oneOf.forEach((rule) => {
    if (rule.test instanceof RegExp && rule.test.test(".js")) {
      rule.options.plugins.push([
        "babel-plugin-secullum-i18n",
        {
          expressionsPath: "./sec-i18n.config.json",
          translateFunction: "translate",
        },
      ]);
    }
  });

  return config;
};

Options

  • expressionsPath: string
    • Path to expressions file.
  • translateFunction: string
    • Name of translate function used on project.