Skip to content

Commit cfd0071

Browse files
Update pattern/web/__init__.py
1 parent 2f49135 commit cfd0071

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

pattern/web/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from builtins import str, bytes, dict, int, chr
1717
from builtins import map, filter, zip
1818
from builtins import object, range, next
19+
from translate import Translator
1920

2021
from .utils import get_url_query, get_form_action, stringify_values, json_iter_parse
2122

@@ -2146,6 +2147,22 @@ def f(v):
21462147
else:
21472148
self._pagination[k] = id
21482149
return results
2150+
2151+
2152+
2153+
def translated(self,lang,query):
2154+
trans_results=self.search(query, start=1, count=10)
2155+
translator= Translator(to_lang=lang)
2156+
translation = translator.translate(trans_results)
2157+
return translation
2158+
2159+
'''
2160+
This translated takes the results from a search query and translates it to the language
2161+
specified by the lang keyword.
2162+
usage===>Twitter.translated("German","cat")
2163+
2164+
'''
2165+
21492166

21502167
def profile(self, query, start=1, count=10, **kwargs):
21512168
""" Returns a list of results for the given author id, alias or search query.

0 commit comments

Comments
 (0)