Module ui.translator

This module translates text using Google Translate.

https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=fr&dt=t&q=alea%20jacta%20est

Functions

Translator:loadPage (text, target_lang, source_lang) Returns decoded JSON table from translate server.
Translator:detect (text) Tries to automatically detect language of text.
Translator:translate (text, target_lang, source_lang) Translate text, returns translation as a single string.
Translator:showTranslation (text, target_lang, source_lang) Show translated text in TextViewer, with alternate translations


Functions

Translator:loadPage (text, target_lang, source_lang)
Returns decoded JSON table from translate server.

Parameters:

Returns:

    string result, or nil
Translator:detect (text)
Tries to automatically detect language of text.

Parameters:

Returns:

    string lang ("en", "fr", )
Translator:translate (text, target_lang, source_lang)
Translate text, returns translation as a single string.

Parameters:

  • text string
  • target_lang string [opt] ("en", "fr", )
  • source_lang string [opt="auto"] ("en", "fr", ) or "auto" to auto-detect source language

Returns:

    string translated text, or nil
Translator:showTranslation (text, target_lang, source_lang)
Show translated text in TextViewer, with alternate translations

Parameters:

  • text string
  • target_lang string [opt] ("en", "fr", )
  • source_lang string [opt="auto"] ("en", "fr", ) or "auto" to auto-detect source language
generated by LDoc 1.4.6 Last updated 2020-03-29 12:40:26