.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
translated.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""MyMemory Translated
3
4"""
5
6# about
7about = {
8 "website": 'https://mymemory.translated.net/',
9 "wikidata_id": None,
10 "official_api_documentation": 'https://mymemory.translated.net/doc/spec.php',
11 "use_official_api": True,
12 "require_api_key": False,
13 "results": 'JSON',
14}
15
16engine_type = 'online_dictionary'
17categories = ['general', 'translate']
18url = 'https://api.mymemory.translated.net/get?q={query}&langpair={from_lang}|{to_lang}{key}'
19web_url = 'https://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}'
20weight = 100
21https_support = True
22
23api_key = ''
24
25
26def request(query, params): # pylint: disable=unused-argument
27 if api_key:
28 key_form = '&key=' + api_key
29 else:
30 key_form = ''
31 params['url'] = url.format(
32 from_lang=params['from_lang'][1], to_lang=params['to_lang'][1], query=params['query'], key=key_form
33 )
34 return params
35
36
37def response(resp):
38 results = []
39 results.append(
40 {
41 'url': web_url.format(
42 from_lang=resp.search_params['from_lang'][2],
43 to_lang=resp.search_params['to_lang'][2],
44 query=resp.search_params['query'],
45 ),
46 'title': '[{0}-{1}] {2}'.format(
47 resp.search_params['from_lang'][1], resp.search_params['to_lang'][1], resp.search_params['query']
48 ),
49 'content': resp.json()['responseData']['translatedText'],
50 }
51 )
52 return results
request(query, params)
Definition translated.py:26