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
module.exports = {
module: {
rules: [
{
test: /\.ini$/,
use: [
{
loader: 'i18n-ini-loader',
options: {
language: 'de',
failOnMissingTranslation: true
}
}
]
}
]
}
}
Output:
module.exports = {
welcome: (name) => `Hallo, ${name}!`,
niceDay: 'Hab einen schönen Tag.'
}
Usage:
Welcome.jsx
import { hello, niceDay } from './messages.ini'
export default function Welcome({ name }) {
return (
<div>
<h1>{hello(name)}</h1>
<span>{niceDay}</span>
</div>
)
}
Options
language
: the language key used for translation (default: en
)failOnMissingTranslation
: whether an Error
should be thrown if missing translations are found (default: true
); if false
, missing translations will be handled gracefully by returning an empty String
(''
)
License
WTFPL – Do What the F*ck You Want to Public License.
Made with :heart: by @MarkTiedemann.