Open Chinese Convert 0.4.3 A project for conversion between Traditional and Simplified Chinese

- Main Page
- Related Pages
- Modules
- Data Structures
- Files
- Examples

- File List
- Globals

All Data Structures Files Functions Variables Groups Pages
opencc.js
Go to the documentation of this file.
1
29 var path = require('path');
30 var binding = require('../build/Release/binding');
31
32 var assetsPath = path.resolve(__dirname, '../build/Release');
33 var getConfigPath = function (config) {
34 var configPath = config;
35 if (config[0] !== '/' && config[1] !== ':') {
36 // Resolve relative path
37 configPath = path.join(assetsPath, config);
38 }
39 return configPath;
40 };
41
49 var OpenCC = module.exports = function (config) {
50 if (!config) {
51 config = 'zhs2zht.ini';
52 }
53 config = getConfigPath(config);
54 this.handler = new binding.Opencc(config);
55 };
56
57
63 OpenCC.CONVERSION_FAST = 0;
64
70 OpenCC.CONVERSION_SEGMENT_ONLY = 1;
71
77 OpenCC.CONVERSION_LIST_CANDIDATES = 2;
78
88 OpenCC.prototype.convert = function (input, callback) {
89 return this.handler.convert(input.toString(), callback);
90 };
91
101 OpenCC.prototype.convertSync = function (input) {
102 return this.handler.convertSync(input.toString());
103 };
104
113 OpenCC.prototype.setConversionMode = function (conversionMode) {
114 return this.handler.setConversionMode(conversionMode);
115 };
OpenCC
OpenCC Node.js API.