0.3.1 • Published 6 years ago

rollup-plugin-i18n v0.3.1

Weekly downloads
167
License
MIT
Repository
github
Last release
6 years ago

rollup-plugin-i18n

Embed your localized text into your bundle.

How to use

In your source code, for example if you have a key called 'msg_hello', to translate it use __('msg_hello')

Config

import i18n from 'rollup-plugin-i18n';

export default {
  entry: 'index.js',
  plugins: [
    i18n({
      language: {
        'msg_hello': 'Hello',
        'msg_world': 'World!',
      },
    }),
  ],
}
// index.js

console.log(__('msg_hello'), __('msg_world'));

Output

Hello World!

Options

  • language: {[key:string]: string}: an object that map from a string key to the localized message

Limitations

Currently we are using a regex to replace all instances of __(<msg>) with their translation. In the future if rollup decides to open up access to the AST we can do a better job of replacement.

0.3.1

6 years ago

0.3.0

6 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago