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, detailed_view, source_lang, target_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, detailed_view, source_lang, target_lang)
Show translated text in TextViewer, with alternate translations

Parameters:

  • text string
  • detailed_view boolean "true" to show alternate translation, definition, additional buttons
  • source_lang string [opt="auto"] ("en", "fr", ) or "auto" to auto-detect source language
  • target_lang string [opt] ("en", "fr", )
generated by LDoc 1.5.0 Last updated 2024-12-19 07:44:17