wyyxdgm / i18n-baidu

i18n via baidu api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

i18n-baidu

通过百度的api实现i18n多语言翻译、npm package

使用方法

  1. npm包安装
npm install i18n-baidu
  1. 百度翻译官网申请接入,获取:AppId、密钥

  2. Snippets,覆盖代码中的 yourKey, yourSecret

const I18nBaidu = require('i18n-baidu');
let i18nBaidu = new I18nBaidu(yourKey, yourSecret);

let postData = {
    q: 'a group of men standing next to each other\n ha ha ',
    from: 'en',
    to: 'zh'
}

i18nBaidu.translate(postData, (res) => {
    if (res) {
        console.log(res);
    }
});

About

i18n via baidu api


Languages

Language:JavaScript 100.0%