@"alberto1998"
There are other translation options, like
https://github.com/LibreTranslate/LibreTranslate
They have a paid option (per month), but they also offer code to install your own local copy for free ( via docker, etc) to where you have a completely offline local server running for free.
And, there are also mirrors that offer free access (of course, mirrors could change, go away, etc).
Based on a free mirror I see, I tested some basic code that works (still would need to develop a full addon, with settings, etc), but this option makes sense for more users (use free mirror or setup own local server for translations or use paid API server) all with the same code (configured with url and optional API key.
Basic python code for kodi addon is as simple as:
------------------------
import xbmc, xbmcgui
import sys
import urllib.request
import json
win = xbmcgui.Window(10000)
win.setProperty("translated_text", '')
def main():
url = "https://translate.argosopentech.com/translate"
values = {'q': sys.argv[1], 'source': 'auto', 'target': 'en', 'format': 'text'}
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
}
data = json.dumps(values).encode("utf-8")
try:
req = urllib.request.Request(url, data, headers)
with urllib.request.urlopen(req) as f:
res = f.read()
result = json.loads(res)
translated_text = str(result['translatedText'])
except Exception as e:
translated_text = str(e)
win.setProperty("translated_text", translated_text)
return ''
if __name__ == '__main__':
main()
---------------------
And the code could be run via skin :
<onload>RunScript(script.XXXXXXXX,$INFO[ListItem.Label])</onload>
( script.XXXXXXXX = whatever name the final addon script is built as )
And then access the result with :
$INFO[Window(Home).Property(translated_text)]