.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.translated Namespace Reference

Functions

 request (query, params)
 
EngineResults response (resp)
 

Variables

dict about
 
str engine_type = 'online_dictionary'
 
list categories = ['general', 'translate']
 
str api_url = "https://api.mymemory.translated.net"
 
str web_url = "https://mymemory.translated.net"
 
int weight = 100
 
bool https_support = True
 
str api_key = ''
 

Detailed Description

MyMemory Translated

Function Documentation

◆ request()

searx.engines.translated.request ( query,
params )

Definition at line 30 of file translated.py.

30def request(query, params): # pylint: disable=unused-argument
31
32 args = {"q": params["query"], "langpair": f"{params['from_lang'][1]}|{params['to_lang'][1]}"}
33 if api_key:
34 args["key"] = api_key
35
36 params['url'] = f"{api_url}/get?{urllib.parse.urlencode(args)}"
37 return params
38
39

◆ response()

EngineResults searx.engines.translated.response ( resp)

Definition at line 40 of file translated.py.

40def response(resp) -> EngineResults:
41 results = EngineResults()
42 data = resp.json()
43
44 args = {
45 "q": resp.search_params["query"],
46 "lang": resp.search_params.get("searxng_locale", "en"), # ui language
47 "sl": resp.search_params['from_lang'][1],
48 "tl": resp.search_params['to_lang'][1],
49 }
50
51 link = f"{web_url}/search.php?{urllib.parse.urlencode(args)}"
52 text = data['responseData']['translatedText']
53
54 examples = [f"{m['segment']} : {m['translation']}" for m in data['matches'] if m['translation'] != text]
55
56 item = results.types.Translations.Item(text=text, examples=examples)
57 results.add(results.types.Translations(translations=[item], url=link))
58
59 return results

Variable Documentation

◆ about

dict searx.engines.translated.about
Initial value:
1= {
2 "website": 'https://mymemory.translated.net/',
3 "wikidata_id": None,
4 "official_api_documentation": 'https://mymemory.translated.net/doc/spec.php',
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 11 of file translated.py.

◆ api_key

str searx.engines.translated.api_key = ''

Definition at line 27 of file translated.py.

◆ api_url

str searx.engines.translated.api_url = "https://api.mymemory.translated.net"

Definition at line 22 of file translated.py.

◆ categories

list searx.engines.translated.categories = ['general', 'translate']

Definition at line 21 of file translated.py.

◆ engine_type

str searx.engines.translated.engine_type = 'online_dictionary'

Definition at line 20 of file translated.py.

◆ https_support

bool searx.engines.translated.https_support = True

Definition at line 25 of file translated.py.

◆ web_url

str searx.engines.translated.web_url = "https://mymemory.translated.net"

Definition at line 23 of file translated.py.

◆ weight

int searx.engines.translated.weight = 100

Definition at line 24 of file translated.py.