Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

i18n-ini-loader

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-ini-loader

Webpack I18n loader based on .ini files.

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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
            }
          }
        ]
      }
    ]
  }
}

// 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:

module.exports = {
  hello: (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>
  )
}

// <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 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.

Keywords

FAQs

Package last updated on 05 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc