i18n-ini-loader
Webpack I18n loader based on .ini files.
Installation
npm install i18n-ini-loader
Quickstart
Input:
messages.ini
[hello]en=Hello, ${name}!de=Hallo, ${name}! [niceDay]en=Have a nice day.de=Hab einen schönen Tag.
Config:
webpack.config.js
moduleexports = module: rules: test: /\.ini$/ use: loader: 'i18n-ini-loader' options: language: 'de' failOnMissingTranslation: true // Note: Since the output of the `i18n-ini-loader` uses ES6 template strings// and arrow functions (see below), you may want to chain the `babel-loader`// for ES5 support.// Check out the `/example` directory for a simple example config.
Output:
moduleexports = `Hallo, !` niceDay: 'Hab einen schönen Tag.'
Usage:
Welcome.jsx
import hello niceDay from './messages.ini' { return <div> <h1></h1> <span>niceDay</span> </div> } // <div>// <h1>Hallo, Mark!</h1>// <span>Hab einen schönen Tag.</span>// </div>
Options
language
: the language key used for translation (default:en
)failOnMissingTranslation
: whether anError
should be thrown if missing translations are found (default:true
); iffalse
, missing translations will be handled gracefully by returning an emptyString
(''
)
License
WTFPL – Do What the F*ck You Want to Public License.
Made with ❤️ by @MarkTiedemann.