本文整理汇总了Python中trans.translate函数的典型用法代码示例。如果您正苦于以下问题:Python translate函数的具体用法?Python translate怎么用?Python translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了translate函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_text
def do_text(text, translit=False):
text = unescape(text)
if markdown_mode:
text = markdown(text)
if translit:
return (translate(text, trans_from, args.trans_to), translate(text, trans_from, "devanagari"))
elif qtags.intersection([".html", ".md"]):
return str(process_html(text, args.media))
else:
return html_escape(text)
示例2: do_text
def do_text(text, translit=False):
text = unescape(text)
if markdown_mode:
text = str(post_markdown(markdown(text)))
if translit:
return (translate(text, trans_from, args.trans_to),
translate(text, trans_from, 'devanagari'))
elif qtags.intersection(['.html', '.md']):
return text
else:
return html_escape(text)
示例3: translate
def translate(root,filename,lang):
print 'Translating', filename
dest_root = root.replace('/ru/','/'+lang+'/')
if not os.path.exists(dest_root):
os.makedirs(dest_root)
input = os.path.join(root,filename)
output = os.path.join(dest_root,filename)
if not os.path.isfile(output):
trans.translate(lang,input,output)
示例4: do_text
def do_text(text, translit=False):
print text, tags ##
text = unescape(text)
if markdown_mode:
text = str(markdown(text))
if translit:
return (translate(text, trans_from, args.trans_to),
translate(text, trans_from, 'devanagari'))
elif tags.intersection(['.html', '.md']):
print qtags, "html or md" ##
return text
else:
return html_escape(text)
示例5: parse_item
def parse_item(self, response, url):
"""
parse the response of a `python requests.get()`
@param response - an object of `requests.get()`
@param url - current url object that has been crawled
@return item
"""
soup = bs4.BeautifulSoup(response.text, 'html.parser')
# print("title: %s" % soup.title)
it = Item()
for link in soup.find_all('meta'):
if link.get('name') == 'description':
it.name_jp = link.get('content')
it.name_zh = trans.translate(it.name_jp)
it.link = response.url
# print("item name_zh: %s" % it.name_zh)
self.feed_new_urls(soup, url)
return it
示例6: post
def post(self):
self.response.headers['Content-Type'] = 'text/plain'
python_string = self.request.get('python_string')
self.response.write(trans.translate(python_string))
示例7: do_trans
def do_trans(text):
return [translate(text, trans_from, args.trans_to),
translate(text, trans_from, 'devanagari')]