Webpack loader for converting Traditional Chinese into Simplified Chinese (and vice versa) using Open Chinese Convert and node-opencc package.
In your webpack.config.js, add opencc-loader as one of the loader for your JavaScript/JSX/TypeScript or text files. The following example translate from Traditional Chinese (Hong Kong) to Simplified Chinese.
{
test : /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loaders: [
'react-hot-loader',
'babel-loader?presets[]=react&presets[]=es2015&presets[]=es2016&presets[]=es2017',
'opencc-loader?translation=hongKongToSimplified'
]
}| Type | Translation |
|---|---|
hongKongToSimplified |
Hong Kong to Simplified Chinese |
simplifiedToHongKong |
Simplified Chinese to Hong Kong |
simplifiedToTraditional |
Simplified Chinese to Traditional Chinese |
simplifiedToTaiwan |
Simplified Chinese to Taiwan |
simplifiedToTaiwanWithPhrases |
Simplified Chinese to Taiwan with phrases |
traditionalToHongKong |
Traditional Chinese to Hong Kong |
traditionalToSimplified |
Traditional Chinese to Simplified Chinese |
traditionalToTaiwan |
Traditional Chinese to Taiwan |
taiwanToSimplified |
Taiwan to Simplified Chinese |
taiwanToSimplifiedWithPhrases |
Taiwan to Simplified Chinese with phrases |
For details of the translation, please refer to node-opencc.
Like us? Star us.
Want to make it better? Fork us and send us a pull request or file an issue.