Git Product home page Git Product logo

free-translate's Introduction

Gabriel Ribeiro

Back-end Developer at Goomer.

Linkedin Badge Gmail Badge

free-translate's People

Contributors

mansi1 avatar ribeirogab 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

Watchers

 avatar

free-translate's Issues

Increase timeout

Increase translation timeout to 30 seconds. is currently in 15 seconds.

    while (!translatedText) {
      await page.goto(
        `https://translate.google.com/?sl=${from}&text=${text}&tl=${to}`,
      );

      await page.waitForTimeout(waitingTime);

      translatedText = await page.evaluate(
        () => document?.querySelector('span[jsname=W297wb]')?.innerHTML,
      );

      waitingTime += 1000;

      if (waitingTime >= 15000) throw new Error('Timeout!');
    }

Translate text

Feature to translate texts in the available languages.

example code:

const { translate } = require('free-translate');
// import { translate } from 'free-translate';

(async () => {
  const translatedText = await translate('hello world', { from: 'en', to: 'pt' });

  console.log(translatedText); // Olá Mundo
})();

Always getting timeout error in Node.js v. 16.13.0

Hi there!
I was trying something really simple like this snippet:

const { translate } = require('free-translate');

(async () => {
const translatedText = await translate('hello world', { from: 'en', to: 'pt' });

console.log(translatedText); // Olá Mundo
})();

But unfortunately, when I execute it with the node .\index.js command, I get the following error after 1 minute:

throw new Error(error_1);
^
Error: Error: .wait() for span[jsname=jqKxS] timed out after 60000msec

Am I doing something wrong?

Getting always timeouts

console.log('en', language, namespace, prepareTranslationKey); const translatedText = await translate(prepareTranslationKey, { from: 'en', to: language });

pl 404 Page ${{path}} was not found.
(node:5377) UnhandledPromiseRejectionWarning: Error: Error: .wait() for span[jsname=jqKxS] timed out after 60000msec

Detect language

Google Translate supports the "auto" option as a parameter.

Implement this functionality in the library, taking into account the following use case:

const { translate } = require('free-translate');
// import { translate } from 'free-translate'; Node.js >= v13

(async () => {
  const translatedText = await translate('eu falo inglês', 'en');

  console.log(translatedText); // I speak English
})();

Translate more than 5000 characters

Google Translate currently supports only 500 characters for translation.

Task:

  • Implement logic to (if the text sent is greater than 5000) divide the text and translate each part separately and then concatenate them

get more output

can you add more params to output maybe something like this

resolve({
    code: 200,
    result: res.text,
    autoCorrected: res.from.text.autoCorrected,
    pronunciation: res.pronunciation,
    from: res.from.language.iso,
    to: To
})

Write a README

Write a README with the necessary documentation for using the library.

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.