0.2.2 • Published 8 years ago

gettext-loader v0.2.2

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

gettext-loader

Build Status

A Webpack loader that compiles Gettext PO files from source code.

Installation

npm install --production gettext-loader

Getting Started

To use gettext-loader you will need a gettext.config.js file in your root directory. This config file contains the header for your PO file as well as the localization methods used in your code.

module.exports = {
  methods: ['__', 'translate'],
  output: 'i18n/en.po',
  header: {
    'Project-Id-Version': '1233',
    'Report-Msgid-Bugs-To':'Jonathan Huang',
    'Last-Translator': 'Jonathan Huang',
    'Language-Team': 'Squad Everywhere',
    'Language': 'en',
    'Plural-Forms': 'nplurals=2; plural=(n != 1);',
    'MIME-Version': '1.0',
    'Content-Type': 'text/plain; charset=UTF-8',
    'Content-Transfer-Encoding': '8bit'
  }
}

Since 'gettext-loader' only parses Javascript (including ES6 and JSX), place it after loaders that transform some source to JS code.

module: {
  loaders: [
    { test: /\.jst/, loaders: ['gettext-loader', 'dot-loader'] },
    { test: /\.jsx?$/, loaders: ['babel', 'gettext-loader'] },
    { test: /\.coffee/, loaders: ['gettext-loader', 'coffee-loader'] }
  ]

gettext-loader does not modify your source code. It only outputs a PO file by parsing your JS source code.

Running Examples

npm install --peer
npm run examples