Skip to content

A powerful language translation package that supports multiple languages using Google's Translator API. Easily translate text between various languages with this simple and efficient package

License

Notifications You must be signed in to change notification settings

Debanjan-San/translate-core

Repository files navigation

Translate-core

A simple package to translate languages

Installation

> npm install translate-core
> yarn add translate-core

Methords

  • supportedLanguages: Returns an array containing all the languages supported by application
  • getTranslate: Translates text from the application's current language to a specified target language
Parameters
  • langTo (string): The target language code to translate the text into. Examples include "en" (English), "es" (Spanish), "fr" (French), and so on. Ensure the language code is supported by your translation library.
  • text (string): The text to be translated.
Returns

An object with two properties:

  • langTo (string): The same target language code passed as input.
  • translatedText (string): The translated text in the specified target language.
Example Usage

You need to intialize the Translate Class before acessing the methods inside it.

const { Translate } = require('translate-core');

(async () => {
    const { getTranslate } = new Translate()
    const text = await getTranslate('en', 'こんにちは!今日はどんなことをお話ししたいですか?')
    console.log(text)
    /*
    Output:
    {
  langTo: 'en',
  translatedText: 'Hello! What would you like to talk about today?'
}
     */
})()

Build with

About

A powerful language translation package that supports multiple languages using Google's Translator API. Easily translate text between various languages with this simple and efficient package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published