@fibjs/translate-by-google-api
v0.1.1
Published
free and unlimited google translation api based on public web api
Downloads
4
Maintainers
Readme
fibjs translate-by-google-api
Install
npm install @fibjs/translate-by-google-api
How to use it
const { translate } = require("@fibjs/translate-by-google-api");
const result = translate('<b>Hello</b>', {
format: 'html',
from: 'en',
to: 'zh-CN'
})
assert.equal(
result.text,
'<b>你好</b>'
)
With html marks,
const { translate } = require("@fibjs/translate-by-google-api");
const result = translate('<a href="https://fibjs.org">fibjs official website</a>', {
format: 'html',
from: 'en',
to: 'zh-CN'
})
assert.equal(
result.text,
'<a href="https://fibjs.org"> fibjs官方网站</a>'
)
NOTICE make sure your environment could access google's api, maybe you need to set proxy to make http client in this package could access google's translation api, just set enviroment variable http_proxy
or all_proxy
.
Test
To test, first make sure you have development dependencies installed. Go to the root folder and do:
npm install
Then, just run the tests.
npm test