Module ui.translator
This module translates text using Google Translate.
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:
- text string
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: