{"action":"created","comment":{"url":"https://api.github.com/repos/WeblateOrg/weblate/pulls/comments/223196925","pull_request_review_id":162273568,"id":223196925,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzE5NjkyNQ==","diff_hunk":"@@ -0,0 +1,99 @@\n+# -*- coding: utf-8 -*-\n+#\n+# Copyright ©2018 Sun Zhigang <hzsunzhigang@corp.netease.com>\n+#\n+# This file is part of Weblate <https://weblate.org/>\n+#\n+# This program is free software: you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation, either version 3 of the License, or\n+# (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with this program.  If not, see <https://www.gnu.org/licenses/>.\n+#\n+\n+from __future__ import unicode_literals\n+\n+from django.conf import settings\n+from django.utils.translation import ugettext_lazy as _\n+\n+from weblate.machinery.base import (\n+    MachineTranslation, MachineTranslationError, MissingConfiguration\n+)\n+\n+import calendar\n+import datetime\n+import random\n+from hashlib import sha1\n+\n+NETEASE_API_ROOT = 'https://jianwai.netease.com/api/text/trans'\n+\n+\n+class NeteaseSightTranslation(MachineTranslation):\n+    \"\"\"Netease Sight API machine translation support.\"\"\"\n+    name = 'Netease Sight'\n+    max_score = 90\n+\n+    # Map codes used by Netease Sight to codes used by Weblate\n+    language_map = {\n+        'zh_Hans': 'zh',\n+    }\n+\n+    def __init__(self):\n+        \"\"\"Check configuration.\"\"\"\n+        super(NeteaseSightTranslation, self).__init__()\n+        if settings.MT_NETEASE_KEY is None:\n+            raise MissingConfiguration(\n+                'Netease Sight Translate requires app key'\n+            )\n+        if settings.MT_NETEASE_SECRET is None:\n+            raise MissingConfiguration(\n+                'Netease Sight Translate requires app secret'\n+            )\n+\n+    def download_languages(self):\n+        \"\"\"List of supported languages.\"\"\"\n+        return [\n+            'zh',\n+            'en',\n+        ]\n+\n+    def authenticate(self, request):\n+        \"\"\"Hook for backends to allow add authentication headers to request.\"\"\"\n+        # Override to add required headers.\n+\n+        nonce = str(random.randint(1000, 99999999))\n+        timestamp = str(1000 * calendar.timegm(datetime.datetime.utcnow().utctimetuple()))\n+\n+        sign = settings.MT_NETEASE_SECRET + nonce + timestamp\n+        sign = sign.encode('utf-8')\n+        sign = sha1(sign).hexdigest()\n+\n+        request.add_header('Content-Type', 'application/json')\n+        request.add_header('appkey', settings.MT_NETEASE_KEY)\n+        request.add_header('nonce', nonce)\n+        request.add_header('timestamp', timestamp)\n+        request.add_header('signature', sign)\n+\n+    def download_translations(self, source, language, text, unit, user):","path":"weblate/machinery/netease.py","position":84,"original_position":84,"commit_id":"3d4b36da81731ed13812c9b67aa12cc3b189a4d2","original_commit_id":"3d4b36da81731ed13812c9b67aa12cc3b189a4d2","user":{"login":"codeclimate[bot]","id":36754821,"node_id":"MDM6Qm90MzY3NTQ4MjE=","avatar_url":"https://avatars0.githubusercontent.com/in/9403?v=4","gravatar_id":"","url":"https://api.github.com/users/codeclimate%5Bbot%5D","html_url":"https://github.com/apps/codeclimate","followers_url":"https://api.github.com/users/codeclimate%5Bbot%5D/followers","following_url":"https://api.github.com/users/codeclimate%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/codeclimate%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/codeclimate%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeclimate%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/codeclimate%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/codeclimate%5Bbot%5D/repos","events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/received_events","type":"Bot","site_admin":false},"body":"Function `download_translations` has 5 arguments (exceeds 4 allowed). Consider refactoring.","created_at":"2018-10-06T23:58:55Z","updated_at":"2018-10-06T23:58:55Z","html_url":"https://github.com/WeblateOrg/weblate/pull/2293#discussion_r223196925","pull_request_url":"https://api.github.com/repos/WeblateOrg/weblate/pulls/2293","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/WeblateOrg/weblate/pulls/comments/223196925"},"html":{"href":"https://github.com/WeblateOrg/weblate/pull/2293#discussion_r223196925"},"pull_request":{"href":"https://api.github.com/repos/WeblateOrg/weblate/pulls/2293"}}},"pull_request":{"url":"https://api.github.com/repos/WeblateOrg/weblate/pulls/2293","id":220877082,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwODc3MDgy","html_url":"https://github.com/WeblateOrg/weblate/pull/2293","diff_url":"https://github.com/WeblateOrg/weblate/pull/2293.diff","patch_url":"https://github.com/WeblateOrg/weblate/pull/2293.patch","issue_url":"https://api.github.com/repos/WeblateOrg/weblate/issues/2293","number":2293,"state":"open","locked":false,"title":"Add Netease Sight translate service","user":{"login":"sunner","id":255413,"node_id":"MDQ6VXNlcjI1NTQxMw==","avatar_url":"https://avatars3.githubusercontent.com/u/255413?v=4","gravatar_id":"","url":"https://api.github.com/users/sunner","html_url":"https://github.com/sunner","followers_url":"https://api.github.com/users/sunner/followers","following_url":"https://api.github.com/users/sunner/following{/other_user}","gists_url":"https://api.github.com/users/sunner/gists{/gist_id}","starred_url":"https://api.github.com/users/sunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunner/subscriptions","organizations_url":"https://api.github.com/users/sunner/orgs","repos_url":"https://api.github.com/users/sunner/repos","events_url":"https://api.github.com/users/sunner/events{/privacy}","received_events_url":"https://api.github.com/users/sunner/received_events","type":"User","site_admin":false},"body":"Netease Sight (https://sight.netease.com/) supports Chinese and English.\r\n\r\nIt requires posting arguments in json format. Therefore, added one parameter to json_req():\r\n\r\n> json_body=False\r\n\r\nSigned-off-by: Sun Zhigang <sunner@gmail.com>\r\n\r\nEnsured that:\r\n\r\n- [x] Every commit has message which describes it\r\n- [x] Every commit is needed on it's own, if you have just minor fixes to previous commits, you can squash them\r\n- [x] Any code changes come with testcase\r\n- [x] Any new functionality is covered by user documentation\r\n","created_at":"2018-10-06T09:58:28Z","updated_at":"2018-10-06T23:58:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"16753d38160a9e06b34b4bf6006e25037b6bf1cd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/WeblateOrg/weblate/milestones/37","html_url":"https://github.com/WeblateOrg/weblate/milestone/37","labels_url":"https://api.github.com/repos/WeblateOrg/weblate/milestones/37/labels","id":3714844,"node_id":"MDk6TWlsZXN0b25lMzcxNDg0NA==","number":37,"title":"3.3","description":"","creator":{"login":"nijel","id":212189,"node_id":"MDQ6VXNlcjIxMjE4OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/212189?v=4","gravatar_id":"","url":"https://api.github.com/users/nijel","html_url":"https://github.com/nijel","followers_url":"https://api.github.com/users/nijel/followers","following_url":"https://api.github.com/users/nijel/following{/other_user}","gists_url":"https://api.github.com/users/nijel/gists{/gist_id}","starred_url":"https://api.github.com/users/nijel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nijel/subscriptions","organizations_url":"https://api.github.com/users/nijel/orgs","repos_url":"https://api.github.com/users/nijel/repos","events_url":"https://api.github.com/users/nijel/events{/privacy}","received_events_url":"https://api.github.com/users/nijel/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":0,"state":"open","created_at":"2018-10-05T12:04:54Z","updated_at":"2018-10-06T18:58:17Z","due_on":"2018-11-15T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/WeblateOrg/weblate/pulls/2293/commits","review_comments_url":"https://api.github.com/repos/WeblateOrg/weblate/pulls/2293/comments","review_comment_url":"https://api.github.com/repos/WeblateOrg/weblate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WeblateOrg/weblate/issues/2293/comments","statuses_url":"https://api.github.com/repos/WeblateOrg/weblate/statuses/3d4b36da81731ed13812c9b67aa12cc3b189a4d2","head":{"label":"sunner:master","ref":"master","sha":"3d4b36da81731ed13812c9b67aa12cc3b189a4d2","user":{"login":"sunner","id":255413,"node_id":"MDQ6VXNlcjI1NTQxMw==","avatar_url":"https://avatars3.githubusercontent.com/u/255413?v=4","gravatar_id":"","url":"https://api.github.com/users/sunner","html_url":"https://github.com/sunner","followers_url":"https://api.github.com/users/sunner/followers","following_url":"https://api.github.com/users/sunner/following{/other_user}","gists_url":"https://api.github.com/users/sunner/gists{/gist_id}","starred_url":"https://api.github.com/users/sunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunner/subscriptions","organizations_url":"https://api.github.com/users/sunner/orgs","repos_url":"https://api.github.com/users/sunner/repos","events_url":"https://api.github.com/users/sunner/events{/privacy}","received_events_url":"https://api.github.com/users/sunner/received_events","type":"User","site_admin":false},"repo":{"id":145419033,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU0MTkwMzM=","name":"weblate","full_name":"sunner/weblate","private":false,"owner":{"login":"sunner","id":255413,"node_id":"MDQ6VXNlcjI1NTQxMw==","avatar_url":"https://avatars3.githubusercontent.com/u/255413?v=4","gravatar_id":"","url":"https://api.github.com/users/sunner","html_url":"https://github.com/sunner","followers_url":"https://api.github.com/users/sunner/followers","following_url":"https://api.github.com/users/sunner/following{/other_user}","gists_url":"https://api.github.com/users/sunner/gists{/gist_id}","starred_url":"https://api.github.com/users/sunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunner/subscriptions","organizations_url":"https://api.github.com/users/sunner/orgs","repos_url":"https://api.github.com/users/sunner/repos","events_url":"https://api.github.com/users/sunner/events{/privacy}","received_events_url":"https://api.github.com/users/sunner/received_events","type":"User","site_admin":false},"html_url":"https://github.com/sunner/weblate","description":"Web based translation tool with tight version control integration.","fork":true,"url":"https://api.github.com/repos/sunner/weblate","forks_url":"https://api.github.com/repos/sunner/weblate/forks","keys_url":"https://api.github.com/repos/sunner/weblate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sunner/weblate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sunner/weblate/teams","hooks_url":"https://api.github.com/repos/sunner/weblate/hooks","issue_events_url":"https://api.github.com/repos/sunner/weblate/issues/events{/number}","events_url":"https://api.github.com/repos/sunner/weblate/events","assignees_url":"https://api.github.com/repos/sunner/weblate/assignees{/user}","branches_url":"https://api.github.com/repos/sunner/weblate/branches{/branch}","tags_url":"https://api.github.com/repos/sunner/weblate/tags","blobs_url":"https://api.github.com/repos/sunner/weblate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sunner/weblate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sunner/weblate/git/refs{/sha}","trees_url":"https://api.github.com/repos/sunner/weblate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sunner/weblate/statuses/{sha}","languages_url":"https://api.github.com/repos/sunner/weblate/languages","stargazers_url":"https://api.github.com/repos/sunner/weblate/stargazers","contributors_url":"https://api.github.com/repos/sunner/weblate/contributors","subscribers_url":"https://api.github.com/repos/sunner/weblate/subscribers","subscription_url":"https://api.github.com/repos/sunner/weblate/subscription","commits_url":"https://api.github.com/repos/sunner/weblate/commits{/sha}","git_commits_url":"https://api.github.com/repos/sunner/weblate/git/commits{/sha}","comments_url":"https://api.github.com/repos/sunner/weblate/comments{/number}","issue_comment_url":"https://api.github.com/repos/sunner/weblate/issues/comments{/number}","contents_url":"https://api.github.com/repos/sunner/weblate/contents/{+path}","compare_url":"https://api.github.com/repos/sunner/weblate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sunner/weblate/merges","archive_url":"https://api.github.com/repos/sunner/weblate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sunner/weblate/downloads","issues_url":"https://api.github.com/repos/sunner/weblate/issues{/number}","pulls_url":"https://api.github.com/repos/sunner/weblate/pulls{/number}","milestones_url":"https://api.github.com/repos/sunner/weblate/milestones{/number}","notifications_url":"https://api.github.com/repos/sunner/weblate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sunner/weblate/labels{/name}","releases_url":"https://api.github.com/repos/sunner/weblate/releases{/id}","deployments_url":"https://api.github.com/repos/sunner/weblate/deployments","created_at":"2018-08-20T13:08:08Z","updated_at":"2018-10-06T23:15:08Z","pushed_at":"2018-10-06T23:15:04Z","git_url":"git://github.com/sunner/weblate.git","ssh_url":"git@github.com:sunner/weblate.git","clone_url":"https://github.com/sunner/weblate.git","svn_url":"https://github.com/sunner/weblate","homepage":"https://weblate.org/","size":188319,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"WeblateOrg:master","ref":"master","sha":"9424edc156db0955c3e9e4bbdca5762eaed921da","user":{"login":"WeblateOrg","id":18286565,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4Mjg2NTY1","avatar_url":"https://avatars2.githubusercontent.com/u/18286565?v=4","gravatar_id":"","url":"https://api.github.com/users/WeblateOrg","html_url":"https://github.com/WeblateOrg","followers_url":"https://api.github.com/users/WeblateOrg/followers","following_url":"https://api.github.com/users/WeblateOrg/following{/other_user}","gists_url":"https://api.github.com/users/WeblateOrg/gists{/gist_id}","starred_url":"https://api.github.com/users/WeblateOrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeblateOrg/subscriptions","organizations_url":"https://api.github.com/users/WeblateOrg/orgs","repos_url":"https://api.github.com/users/WeblateOrg/repos","events_url":"https://api.github.com/users/WeblateOrg/events{/privacy}","received_events_url":"https://api.github.com/users/WeblateOrg/received_events","type":"Organization","site_admin":false},"repo":{"id":3559019,"node_id":"MDEwOlJlcG9zaXRvcnkzNTU5MDE5","name":"weblate","full_name":"WeblateOrg/weblate","private":false,"owner":{"login":"WeblateOrg","id":18286565,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4Mjg2NTY1","avatar_url":"https://avatars2.githubusercontent.com/u/18286565?v=4","gravatar_id":"","url":"https://api.github.com/users/WeblateOrg","html_url":"https://github.com/WeblateOrg","followers_url":"https://api.github.com/users/WeblateOrg/followers","following_url":"https://api.github.com/users/WeblateOrg/following{/other_user}","gists_url":"https://api.github.com/users/WeblateOrg/gists{/gist_id}","starred_url":"https://api.github.com/users/WeblateOrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeblateOrg/subscriptions","organizations_url":"https://api.github.com/users/WeblateOrg/orgs","repos_url":"https://api.github.com/users/WeblateOrg/repos","events_url":"https://api.github.com/users/WeblateOrg/events{/privacy}","received_events_url":"https://api.github.com/users/WeblateOrg/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/WeblateOrg/weblate","description":"Web based translation tool with tight version control integration.","fork":false,"url":"https://api.github.com/repos/WeblateOrg/weblate","forks_url":"https://api.github.com/repos/WeblateOrg/weblate/forks","keys_url":"https://api.github.com/repos/WeblateOrg/weblate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WeblateOrg/weblate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WeblateOrg/weblate/teams","hooks_url":"https://api.github.com/repos/WeblateOrg/weblate/hooks","issue_events_url":"https://api.github.com/repos/WeblateOrg/weblate/issues/events{/number}","events_url":"https://api.github.com/repos/WeblateOrg/weblate/events","assignees_url":"https://api.github.com/repos/WeblateOrg/weblate/assignees{/user}","branches_url":"https://api.github.com/repos/WeblateOrg/weblate/branches{/branch}","tags_url":"https://api.github.com/repos/WeblateOrg/weblate/tags","blobs_url":"https://api.github.com/repos/WeblateOrg/weblate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WeblateOrg/weblate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WeblateOrg/weblate/git/refs{/sha}","trees_url":"https://api.github.com/repos/WeblateOrg/weblate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WeblateOrg/weblate/statuses/{sha}","languages_url":"https://api.github.com/repos/WeblateOrg/weblate/languages","stargazers_url":"https://api.github.com/repos/WeblateOrg/weblate/stargazers","contributors_url":"https://api.github.com/repos/WeblateOrg/weblate/contributors","subscribers_url":"https://api.github.com/repos/WeblateOrg/weblate/subscribers","subscription_url":"https://api.github.com/repos/WeblateOrg/weblate/subscription","commits_url":"https://api.github.com/repos/WeblateOrg/weblate/commits{/sha}","git_commits_url":"https://api.github.com/repos/WeblateOrg/weblate/git/commits{/sha}","comments_url":"https://api.github.com/repos/WeblateOrg/weblate/comments{/number}","issue_comment_url":"https://api.github.com/repos/WeblateOrg/weblate/issues/comments{/number}","contents_url":"https://api.github.com/repos/WeblateOrg/weblate/contents/{+path}","compare_url":"https://api.github.com/repos/WeblateOrg/weblate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WeblateOrg/weblate/merges","archive_url":"https://api.github.com/repos/WeblateOrg/weblate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WeblateOrg/weblate/downloads","issues_url":"https://api.github.com/repos/WeblateOrg/weblate/issues{/number}","pulls_url":"https://api.github.com/repos/WeblateOrg/weblate/pulls{/number}","milestones_url":"https://api.github.com/repos/WeblateOrg/weblate/milestones{/number}","notifications_url":"https://api.github.com/repos/WeblateOrg/weblate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WeblateOrg/weblate/labels{/name}","releases_url":"https://api.github.com/repos/WeblateOrg/weblate/releases{/id}","deployments_url":"https://api.github.com/repos/WeblateOrg/weblate/deployments","created_at":"2012-02-27T09:33:29Z","updated_at":"2018-10-06T18:38:52Z","pushed_at":"2018-10-06T23:15:07Z","git_url":"git://github.com/WeblateOrg/weblate.git","ssh_url":"git@github.com:WeblateOrg/weblate.git","clone_url":"https://github.com/WeblateOrg/weblate.git","svn_url":"https://github.com/WeblateOrg/weblate","homepage":"https://weblate.org/","size":188369,"stargazers_count":1155,"watchers_count":1155,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":324,"mirror_url":null,"archived":false,"open_issues_count":198,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":324,"open_issues":198,"watchers":1155,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WeblateOrg/weblate/pulls/2293"},"html":{"href":"https://github.com/WeblateOrg/weblate/pull/2293"},"issue":{"href":"https://api.github.com/repos/WeblateOrg/weblate/issues/2293"},"comments":{"href":"https://api.github.com/repos/WeblateOrg/weblate/issues/2293/comments"},"review_comments":{"href":"https://api.github.com/repos/WeblateOrg/weblate/pulls/2293/comments"},"review_comment":{"href":"https://api.github.com/repos/WeblateOrg/weblate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WeblateOrg/weblate/pulls/2293/commits"},"statuses":{"href":"https://api.github.com/repos/WeblateOrg/weblate/statuses/3d4b36da81731ed13812c9b67aa12cc3b189a4d2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"codeclimate"}}