Giter Club home page Giter Club logo

bing-translate-api's Introduction

Hi there 👋

Thank you for visiting! Have a nice day~ ✨

bing-translate-api's People

Contributors

ctnkaan avatar dependabot[bot] avatar guoyunhe avatar marmot-z avatar plainheart avatar sabereen avatar suejon avatar victor-heliomar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bing-translate-api's Issues

failed to fetch IG and IID RequestError: read ECONNRESET

是不是匿名已经无法使用了呢?

failed to fetch IG and IID RequestError: read ECONNRESET
    at ClientRequest.<anonymous> (D:\Programming\nodescraping\node_modules\bing-translate-api\node_modules\got\dist\source\core\index.js:956:111)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:327:22)
    at ClientRequest.origin.emit (D:\Programming\nodescraping\node_modules\bing-translate-api\node_modules\@szmarczak\http-timer\dist\source\index.js:39:20)
    at TLSSocket.socketErrorListener (_http_client.js:469:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20) {
  code: 'ECONNRESET',
  timings: {
    start: 1615619504845,
    socket: 1615619504845,
    lookup: 1615619504869,
    connect: 1615619507828,
    secureConnect: undefined,
    upload: undefined,
    response: undefined,
    end: undefined,
    error: 1615619510679,
    abort: undefined,
    phases: {
      wait: 0,
      dns: 24,
      tcp: 2959,
      tls: undefined,
      request: undefined,
      firstByte: undefined,
      download: undefined,
      total: 5834
    }
  }
}

RequestError: read ECONNRESET
    at ClientRequest.<anonymous> (D:\Programming\nodescraping\node_modules\bing-translate-api\node_modules\got\dist\source\core\index.js:956:111)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:327:22)
    at ClientRequest.origin.emit (D:\Programming\nodescraping\node_modules\bing-translate-api\node_modules\@szmarczak\http-timer\dist\source\index.js:39:20)
    at TLSSocket.socketErrorListener (_http_client.js:469:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20) {
  code: 'ECONNRESET',
  timings: {
    start: 1615619504875,
    socket: 1615619504875,
    lookup: 1615619504875,
    connect: 1615619507827,
    secureConnect: undefined,
    upload: undefined,
    response: undefined,
    end: undefined,
    error: 1615619510694,
    abort: undefined,
    phases: {
      wait: 0,
      dns: 0,
      tcp: 2952,
      tls: undefined,
      request: undefined,
      firstByte: undefined,
      download: undefined,
      total: 5819
    }
  }
}
RequestError: read ECONNRESET
    at ClientRequest.<anonymous> (D:\Programming\nodescraping\node_modules\bing-translate-api\node_modules\got\dist\source\core\index.js:956:111)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:327:22)
    at ClientRequest.origin.emit (D:\Programming\nodescraping\node_modules\bing-translate-api\node_modules\@szmarczak\http-timer\dist\source\index.js:39:20)
    at TLSSocket.socketErrorListener (_http_client.js:469:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20) {
  code: 'ECONNRESET',
  timings: {
    start: 1615619504858,
    socket: 1615619504858,
    lookup: 1615619504870,
    connect: 1615619507828,
    secureConnect: undefined,
    upload: undefined,
    response: undefined,
    end: undefined,
    error: 1615619510697,
    abort: undefined,
    phases: {
      wait: 0,
      dns: 12,
      tcp: 2958,
      tls: undefined,
      request: undefined,
      firstByte: undefined,
      download: undefined,
      total: 5839
    }
  }
}

v2.9.1 'RequestError' code:'ERR_TLS_CERT_ALTNAME_INVALID'

2.9.1翻译出错,极少次成功。
在源代码调试中定位到 “fetchGlobalConfig” 函数 catch (e) {
console.error('failed to fetch global config', e)
throw e
} 此处抛出错误。
以下是 catch e对象的部分内容:

{
code:'ERR_TLS_CERT_ALTNAME_INVALID'
name:'RequestError',
timings: {start: 1684146043656, socket: 1684146043662, lookup: 1684146043663, connect: 1684146043765, secureConnect: undefined,},
message: 'Hostname/IP does not match certificate's altnames: Host: cn.bing.com. is not in the cert's altnames: DNS:*.media.microsoftstream.com, DNS:*.azureedge.net, DNS:*.origin.mediaservices.windows.net, DNS:*.streaming.mediaservices.windows.net',

code: 'ERR_TLS_CERT_ALTNAME_INVALID'
name: 'RequestError'
timings: {start: 1684146043656, socket: 1684146043662, lookup: 1684146043663, connect: 1684146043765, secureConnect: undefined,}
message: 'Hostname/IP does not match certificate's altnames: Host: cn.bing.com. is not in the cert's altnames: DNS:*.media.microsoftstream.com, DNS:*.azureedge.net, DNS:*.origin.mediaservices.windows.net, DNS:*.streaming.mediaservices.windows.net'

agent: undefined
allowGetBody: false
cache: undefined
cacheHeuristic: undefined
cacheOptions: {}
decompress: true
dnsCache: undefined
followRedirect: true
headers: {user-agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) A…like Gecko) Chrome/110.0.0.0 Safari/537.36', accept-encoding: 'gzip, deflate, br'}
http2: false
https: undefined
ignoreCargoCult: undefined
ignoreInvalidCookies: false
immutableMinTimeToLive: undefined
isStream: false
maxRedirects: 10
method: 'GET'
password: ''
prefixUrl: () => prefixUrl
request: { 
requestUrl:'https://bing.com/translator'.}
responseType: 'text'
response: { url:'https://bing.com/translator', requestUrl:'https://bing.com/translator',statusCode:
301, statusMessage: 'Moved Permanently', ip:'204.79.197.200' }

}

Response code 404 (Not Found)

This library worked correctly yesterday, but stopped working earlier today. The translate function returns a Response code 404 (Not Found) error.

Perhaps the translate endpoint has changed url?

HttpError: 205 status code (Reset Content)

Hello, I ran the example from the Usage block and the status code 205 is always returned.

Example code

const { translate } = require('bing-translate-api');

translate('你好', null, 'en', true).then(res => {
  console.log(res.translation);
}).catch(err => {
  console.error(err);
});

Return

Error: Something went wrong! The response is {"statusCode":205,"errorMessage":""}.
    at translate (C:\Users\dmitry\projects\NEST\translator\node_modules\bing-translate-api\src\index.js:193:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Yesterday it worked like it should. Is this normal behavior or something new?

Ratelimiting

Hi, I was wondering if Bing rate-limit's translations to their POST api system. If so, would you happen to know the rate? I just want to know the reliability/max of Bing's translation system without using proxies.

Maximum text lenght is 1000

Hello, I encountered a problem. When the text length is more than 1000 characters, the package throws an error. The error appears to be caused by the Bing Translation API reaching its maximum text length. How can I solve this problem? I would also like to use your package with longer texts. I would be glad if you help. Thanks.

Implemented this library using java language

Hi, plainheart. Thank you very much for developing such a useful toolkit. Recently I wanted to use bing translate to implement some translation functions, but unfortunately there is no similar toolkit in the java ecosystem, so I imitated this project. A java version of the tool was created. If you want, can you link it to Related projects in the README?

Request code 429

Is there any way to prevent it, using auto detector for the input language

Something went wrong! The response is {"statusCode":205,"errorMessage":""}

const { translate } = require('bing-translate-api');
const translationFunction = async (vocabulary, mainLanguage, languageTo) => {
try {
const res = await translate(vocabulary.toLowerCase(), mainLanguage, languageTo, true)
return res
} catch (error) {
return error
}
}
module.exports = translationFunction

This is my node.js code piece. All values are correct and the system was worked before nearly 1 months ago. But nowadays that error shown.
The response is Something went wrong! The response is {"statusCode":205,"errorMessage":""}. The status 205 is reset content but I can't find any relation with the code.
Please can you fix that

"name":"HTTPError","code":"ERR_NON_2XX_3XX_RESPONSE"

近期出现以下问题,我看到一个相似的issues,但我这边没有短期多次请求

{"name":"HTTPError","code":"ERR_NON_2XX_3XX_RESPONSE","timings":{"start":1699604582921,"socket":1699604582925,"lookup":1699604582979,"connect":1699604583017,"secureConnect":1699604583059,"upload":1699604583059,"response":1699604603159,"end":1699604603163,"phases":{"wait":4,"dns":54,"tcp":38,"tls":42,"request":0,"firstByte":20100,"download":4,"total":20242}}}

only call once

when can twice, it will be crash.
RequestError: Socket connection timeout

Browser compatibility

Thanks for the nice library - I'm wondering if there is a way to use it in the browser? I've tried browserify, but got seems not to be compatible. Any suggestions?

Cannot read property 'translations' of undefined

This error occurs after doing lots (around 500 in 30 minutes) of translations
TypeError: Cannot read property 'translations' of undefined at translate (/home/runner/Bibletranslation/node_modules/bing-translate-api/src/index.js:117:31) at processTicksAndRejections (internal/process/task_queues.js:97:5)
I used the same code as in the docs to test.

Its not ratelimiting i think, opening up bing.com and writing some quick code to ping their servers with translations works.

[v4 Release] New `MET` Mode for Microsoft Translator

Hi all,

A new MET mode is under development and will be released soon. The free service is still available together with the Bing translator (legacy WEBSITE mode & EPT mode) and meanwhile, it supports batch translation, more languages than the EPT mode added since v3.0.0 and allows you to use the paid service with your private key for better stability.

Feel free to get a taste of the new mode in the v4-MET branch and leave your comments!

Limitations & Tips:

  • The correction service is not available.
  • The returned translation result is different from the form in v3.0.0 or older versions. It will be the original response from the Microsoft translator.
  • Refer to [1] for the supported languages and features of Microsoft translator.

[1] https://learn.microsoft.com/azure/ai-services/translator/reference/rest-api-guide

source language NL not recognized

It translates from English to other languages fine.
But it doesn't seem to want to translate from Dutch to English?

It seems to ignore that i'm using dutch and chooses German instead, either way i don't get English.

I'm using https://www.npmjs.com/package/bing-translate-api

code

      console.log(msg);
      console.log(source_lang);
      console.log(target_lang);

      translate(msg, source_lang, target_lang, true, true).then(res => {
        console.log(res);
      }).catch(err => {
        console.error(err);
      });

result

was sold ichor sagen
nl
en

{
  text: 'was sold ichor sagen',
  userLang: 'nl',
  translation: 'was sold ichor sagen',
  language: { from: 'de', to: 'en', score: 1 },
  correctedText: 'was soll ich sagen',
  raw: [ { translations: [Array], detectedLanguage: [Object] } ]
}

TypeError: Cannot read property '1' of null

TypeError: Cannot read property '1' of null
at fetchGlobalConfig (node_modules\bing-translate-api\src\index.js:65:36)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Object.translate (node_modules\bing-translate-api\src\index.js:139:3)

IG = body.match(/IG:"([^"]+)"/)[1]

crash: redirects is empty

Description

The API may have changed, redirects returned is empty, so it throws.

image

image

Workaround

hardcode subdomain as "www" or use requestUrl as redirects[0] fallback

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.