1.0.0 • Published 7 years ago

webpack-extract-oftn-l10n v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

webpack-extract-oftn-l10n

This Webpack plugin allows you to automatically export localization strings from applications using the oftn-l10n library. No need to duplicate effort!

It looks for every reference to R.<property> and at every comment looking for R.<property> = <string>. A Russian translator can create a new translation by copying this file to ru.json and changing the language tag from "" to "ru".

Usage

Install the plugin:

npm install --save-dev webpack-extract-oftn-l10n

And then include it in your configuration:

const path = require('path');
const fs = require('fs');
const ExtractStringsPlugin = require('webpack-extract-oftn-l10n.js');

module.exports = {
  entry: './test.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },
  plugins: [new ExtractStringsPlugin({
    variable: 'R',
    output: path.join(__dirname, 'localizations/default.json')
  })]
};

Options

OptionTypeDefault
variablestring"R"The name of the identifier to search for which accesses the translation.
outputstring | booleanfalseThe path of the localization file to create.

See oftn-l10n-example to view a more detailed example using this library.