1.1.2 • Published 7 years ago

topbuzz-i18n-webpack-plugin v1.1.2

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

Install

npm i -D topbuzz-i18n-webpack-plugin

Usage

This plugin will extract all text items for i18n into different files, classify with different js packages. example:

{
  "js/pgc/signin": {
    "PasswordLengthWrong": "パスワードは、6文字以上が必要です",
    "PasswordSpaceWrong": "パスワードの最初と最後にスペースを使うことはできませんが、それ以外の場所には使うことができます",
    "SignMethodEmail": "Emailで無料会員登録する"
  },
  "js/pgc/fault": {
    "ErrorWhoops": "...あれ?...",
    "Error404": "該当するページは見つかりませんでした。",
    "Error500": "エラーが発生しました。再度お試しください。",
    "GoHome": "ホームへ"
  }
}

the package name is the some as webpack entry file

Options

plugins: [
  ...
  new I18nPlugin(languageConfig, optionsObj)
],
  • optionsObj.objectName: the default value is __, you can change it to other function name.
  • optionsObj.devPath: the default value is ./, which defalut path to write files, when start in webpack dev server.
  • optionsObj.outputPath: the default value is output path in webpack config, which defalut path to write files.
  • optionsObj.fileMap: the default value is {}, which will map the text items in different files into the same one.

objectName is different when you use import(es6 commonjs) or require; require i18n file just set modules name, ##example

  new I18nPlugin(localization, {
    devPath: './output_source',
    objectName: '_localization2.default',
    fileMap: {
      'js/pgc/earning-setting': 'js/pgc/revenue',
      'js/pgc/earning-billing': 'js/pgc/revenue',
      'js/pgc/earning-contract': 'js/pgc/revenue',
      'js/pgc/earning-overview': 'js/pgc/revenue',
      'js/pgc/stats-summary': 'js/pgc/statistics',
      'js/pgc/stats-video-analysis': 'js/pgc/statistics',
      'js/pgc/stats-content-detail': 'js/pgc/statistics'
    }
  })

Maintainers

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago