{"id":17045896,"url":"https://github.com/littlecodersh/translation","last_synced_at":"2025-07-14T09:38:04.708Z","repository":{"id":57476950,"uuid":"61265863","full_name":"littlecodersh/translation","owner":"littlecodersh","description":"Python translation package","archived":false,"fork":false,"pushed_at":"2017-08-17T09:59:18.000Z","size":26,"stargazers_count":55,"open_issues_count":6,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-26T10:03:41.716Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/littlecodersh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-16T05:52:09.000Z","updated_at":"2024-11-01T10:34:34.000Z","dependencies_parsed_at":"2022-09-14T16:41:19.020Z","dependency_job_id":null,"html_url":"https://github.com/littlecodersh/translation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlecodersh%2Ftranslation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlecodersh%2Ftranslation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlecodersh%2Ftranslation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littlecodersh%2Ftranslation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/littlecodersh","download_url":"https://codeload.github.com/littlecodersh/translation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248589250,"owners_count":21129574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T09:42:39.642Z","updated_at":"2025-04-12T15:30:39.884Z","avatar_url":"https://github.com/littlecodersh.png","language":"Python","funding_links":[],"categories":["Feature Extraction"],"sub_categories":["Text/NLP"],"readme":"# translation\r\n\r\n![python27](https://img.shields.io/badge/python-2.7-ff69b4.svg) ![python35](https://img.shields.io/badge/python-3.5-green.svg) [English version](https://github.com/littlecodersh/translation/blob/master/README_EN.md)\r\n\r\ntranslation是一个基于网页端翻译的python翻译包。\r\n\r\n提供基本的谷歌、有道、百度、金山翻译服务。\r\n\r\n目前提供的谷歌的翻译服务暂时不需要使用代理。\r\n\r\n## Installation\r\n\r\n```bash\r\npip install translation\r\n```\r\n\r\n## Usage\r\n\r\n```python\r\nfrom translation import baidu, google, youdao, iciba\r\n\r\nprint(google('hello world!', dst = 'zh-CN'))\r\nprint(google('hello world!', dst = 'ru'))\r\nprint(baidu('hello world!', dst = 'zh'))\r\nprint(baidu('hello world!', dst = 'ru'))\r\nprint(youdao('hello world!', dst = 'zh-CN'))\r\nprint(iciba('hello world!', dst = 'zh'))\r\nprint(bing('hello world!', dst = 'zh-CHS'))\r\n```\r\n\r\n## Documents\r\n\r\n你可以在[这里](http://translation.readthedocs.io/zh_CN/latest/)获取api的使用帮助。\r\n\r\n## Advanced usage\r\n\r\n### Proxies\r\n\r\n你可能无法在国内使用谷歌或者在国外使用有道和金山的翻译。\r\n\r\n这是你可以尝试使用代理。\r\n\r\n```python\r\nfrom translation import google, ConnectError\r\n\r\n# 127.0.0.1:1080 is a vaild proxies\r\ntry:\r\n    print(google('hello world!', dst = 'zh-CN', proxies = {'http': '127.0.0.1:1080'}))\r\nexcept ConnectError:\r\n    print('Invaild proxy')\r\n```\r\n\r\n### Default\r\n\r\n你可以更改默认的设置，可更改的设置包括：\r\n* 默认的源语言（不修改则会自动识别）\r\n* 默认的目标语言（不修改则为中文）\r\n* 默认的首选翻译（不修改则为有道）\r\n* 默认的代理（不修改则为不使用代理）\r\n\r\n```python\r\nfrom translation import (set_default_translation, set_default_language,\r\n    set_default_proxies, get, ConnectError)\r\n\r\nset_default_translation('google')\r\nset_default_language('auto', 'zh-CN')\r\nset_default_proxies({'http': '127.0.0.1:1080'})\r\ntry:\r\n    print(get('hello world!'))\r\nexcept ConnectError:\r\n    print('Invaild proxy')\r\n```\r\n\r\n### More\r\n\r\n更多的功能可以参考[文档](http://translation.readthedocs.io/zh_CN/latest/)。\r\n\r\n## Language\r\n\r\n[文档](http://translation.readthedocs.io/zh_CN/latest/)中有详细的支持语言的列表，这里仅给出谷歌支持语言的标记列表。\r\n\r\n其中金山词霸，有道翻译仅支持文档给出的语言翻译为中文。\r\n\r\n**Google**\r\n```\r\nel    : Greek,\r\neo    : Esperanto,\r\nen    : English,\r\naf    : Afrikaans,\r\nsw    : Swahili,\r\nca    : Catalan,\r\nit    : Italian,\r\niw    : Hebrew,\r\nsv    : Swedish,\r\ncs    : Czech,\r\ncy    : Welsh,\r\nar    : Arabic,\r\nur    : Urdu,\r\nga    : Irish,\r\neu    : Basque,\r\net    : Estonian,\r\naz    : Azerbaijani,\r\nid    : Indonesian,\r\nes    : Spanish,\r\nru    : Russian,\r\ngl    : Galician,\r\nnl    : Dutch,\r\npt    : Portuguese,\r\nla    : Latin,\r\ntr    : Turkish,\r\ntl    : Filipino,\r\nlv    : Latvian,\r\nlt    : Lithuanian,\r\nth    : Thai,\r\nvi    : Vietnamese,\r\ngu    : Gujarati,\r\nro    : Romanian,\r\nis    : Icelandic,\r\npl    : Polish,\r\nta    : Tamil,\r\nyi    : Yiddish,\r\nbe    : Belarusian,\r\nfr    : French,\r\nbg    : Bulgarian,\r\nuk    : Ukrainian,\r\nhr    : Croatian,\r\nbn    : Bengali,\r\nsl    : Slovenian,\r\nht    : Haitian Creole,\r\nda    : Danish,\r\nfa    : Persian,\r\nhi    : Hindi,\r\nfi    : Finnish,\r\nhu    : Hungarian,\r\nja    : Japanese,\r\nka    : Georgian,\r\nte    : Telugu,\r\nzh-TW : Chinese Traditional,\r\nsq    : Albanian,\r\nno    : Norwegian,\r\nko    : Korean,\r\nkn    : Kannada,\r\nmk    : Macedonian,\r\nzh-CN : Chinese Simplified,\r\nsk    : Slovak,\r\nmt    : Maltese,\r\nde    : German,\r\nms    : Malay,\r\nsr    : Serbian\r\n```\r\n\r\n## Comments\r\n\r\n如果有什么问题或者建议都可以在这个[Issue](https://github.com/littlecodersh/translation/issues/1)和我讨论。\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittlecodersh%2Ftranslation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittlecodersh%2Ftranslation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittlecodersh%2Ftranslation/lists"}