Skip to content

iMuFeng/gettext-html-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gettext Html Plugin

Install

npm install gettext-html-plugin --save-dev

Useage

webpack.config.js

const HtmlWebpackPlugin = require('html-webpack-plugin')
const GettextHtmlPlugin = require('gettext-html-plugin')

module.exports = {
  entry: {
    index: 'index.js'
  },
  output: {
    path: __dirname + '/dist',
    filename: 'index.js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: __dirname + '/index.html',
      chunks: ['index']
    }),
    new HtmlWebpackPlugin({
      filename: 'zh-cn.html',
      template: __dirname + '/index.html',
      chunks: ['index']
    }),
    new GettextHtmlPlugin({
      langsPath: __dirname + '/langs',
      sources: {
        'zh-cn.html': 'zh_CN'
      }
    })
  ]
}

Options

Name Type Default Description
prefix {String} {{ Prefix of package untranslated text
suffix {String} }} Suffix of package untranslated text
langsPath {String} null Translation text path
injectLang {Boolean} true Modify the html lang attribute and add a language to the body class name
regenerateLangFile {Boolean} true Automatically regenerate translated text after modifying html
sources {Object} {} Relationships of html and translation language

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published