{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/pontoon/pulls/comments/116959375","pull_request_review_id":38621688,"id":116959375,"diff_hunk":"@@ -591,3 +595,53 @@ def convert_to_unix_time(my_datetime):\n     Convert datetime object to UNIX time\n     \"\"\"\n     return int(time.mktime(my_datetime.timetuple()) * 1000)\n+\n+\n+def build_translation_memory_file(creation_date, locale_code, entries):\n+    \"\"\"\n+    TMX files will contain large amount of entries and it's impossible to render all the data with django templates.\n+    Rendering of string in memory is a lot faster.\n+    :param datetime creation_date: when TMX file is being created.\n+    :param str locale_code: code of a locale\n+    :param list entries: A list which contains tuples with following items:\n+                         * resource_path - path of a resource,\n+                         * key - key of an entity,\n+                         * source - source string of entity,\n+                         * target - translated string,\n+                         * project_name - name of a project,\n+                         * project_slug - slugified name of a project,\n+    \"\"\"\n+    yield (\n+        u'<?xml version=\"1.0\" encoding=\"utf-8\" ?>'\n+        u'\\n<tmx version=\"1.4\">'\n+        u'\\n\\t<header'\n+        u' creationtoolversion=\"0.1\"'\n+        u' creationtool=\"pontoon\"'\n+        u' datatype=\"plaintext\"'\n+        u' segtype=\"sentence\"'\n+        u' o-tmf=\"plain text\"'\n+        u' srclang=\"en-US\"'\n+        u' creationdate=\"%(creation_date)s\">\\n\\t</header>\\n\\t<body>' % {\n+            'creation_date': creation_date.isoformat()\n+        }\n+    )\n+\n+    for resource_path, key, source, target, project_name, project_slug in entries:\n+        yield (\n+            u'\\n\\t<tu id=%(tuid)s srclang=\"en-US\">'\n+            u'\\n\\t\\t<tuv xml:lang=\"en-US\">'\n+            u'\\n\\t\\t\\t<seg>%(source)s</seg>'\n+            u'\\n\\t\\t</tuv>'\n+            u'\\n\\t\\t<tuv xml:lang=%(locale_code)s>'\n+            u'\\n\\t\\t\\t<seg>%(target)s</seg>'\n+            u'\\n\\t\\t</tuv>'\n+            u'\\n\\t</tu>' % {","path":"pontoon/base/utils.py","position":55,"original_position":55,"commit_id":"fa052c0c28720ce261ddf01f58ca4b543f80b6e4","original_commit_id":"fa052c0c28720ce261ddf01f58ca4b543f80b6e4","user":{"login":"mathjazz","id":626716,"avatar_url":"https://avatars1.githubusercontent.com/u/626716?v=3","gravatar_id":"","url":"https://api.github.com/users/mathjazz","html_url":"https://github.com/mathjazz","followers_url":"https://api.github.com/users/mathjazz/followers","following_url":"https://api.github.com/users/mathjazz/following{/other_user}","gists_url":"https://api.github.com/users/mathjazz/gists{/gist_id}","starred_url":"https://api.github.com/users/mathjazz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathjazz/subscriptions","organizations_url":"https://api.github.com/users/mathjazz/orgs","repos_url":"https://api.github.com/users/mathjazz/repos","events_url":"https://api.github.com/users/mathjazz/events{/privacy}","received_events_url":"https://api.github.com/users/mathjazz/received_events","type":"User","site_admin":false},"body":"All these lines need an additional `\\t`, otherwise they are nested on the same level as `<body>`.","created_at":"2017-05-17T10:02:04Z","updated_at":"2017-05-17T10:02:35Z","html_url":"https://github.com/mozilla/pontoon/pull/606#discussion_r116959375","pull_request_url":"https://api.github.com/repos/mozilla/pontoon/pulls/606","_links":{"self":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/comments/116959375"},"html":{"href":"https://github.com/mozilla/pontoon/pull/606#discussion_r116959375"},"pull_request":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/606"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/pontoon/pulls/606","id":119994808,"html_url":"https://github.com/mozilla/pontoon/pull/606","diff_url":"https://github.com/mozilla/pontoon/pull/606.diff","patch_url":"https://github.com/mozilla/pontoon/pull/606.patch","issue_url":"https://api.github.com/repos/mozilla/pontoon/issues/606","number":606,"state":"open","locked":false,"title":"Fix bug 1333850. Add download of translation memory.","user":{"login":"jotes","id":8784972,"avatar_url":"https://avatars1.githubusercontent.com/u/8784972?v=3","gravatar_id":"","url":"https://api.github.com/users/jotes","html_url":"https://github.com/jotes","followers_url":"https://api.github.com/users/jotes/followers","following_url":"https://api.github.com/users/jotes/following{/other_user}","gists_url":"https://api.github.com/users/jotes/gists{/gist_id}","starred_url":"https://api.github.com/users/jotes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jotes/subscriptions","organizations_url":"https://api.github.com/users/jotes/orgs","repos_url":"https://api.github.com/users/jotes/repos","events_url":"https://api.github.com/users/jotes/events{/privacy}","received_events_url":"https://api.github.com/users/jotes/received_events","type":"User","site_admin":false},"body":"TODO:\r\n* [x] discuss TMX structure\r\n* [x] clean up TMX generator\r\n* [x] add tests\r\n* [ ] add test to verify dtd (or check if Element Tree does it for us).","created_at":"2017-05-10T22:50:14Z","updated_at":"2017-05-17T10:02:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fe586ac9fe0c924bba62eabb9870d2967c8f711a","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/pontoon/pulls/606/commits","review_comments_url":"https://api.github.com/repos/mozilla/pontoon/pulls/606/comments","review_comment_url":"https://api.github.com/repos/mozilla/pontoon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/pontoon/issues/606/comments","statuses_url":"https://api.github.com/repos/mozilla/pontoon/statuses/fa052c0c28720ce261ddf01f58ca4b543f80b6e4","head":{"label":"jotes:bug-1333850-download-translation-memory","ref":"bug-1333850-download-translation-memory","sha":"fa052c0c28720ce261ddf01f58ca4b543f80b6e4","user":{"login":"jotes","id":8784972,"avatar_url":"https://avatars1.githubusercontent.com/u/8784972?v=3","gravatar_id":"","url":"https://api.github.com/users/jotes","html_url":"https://github.com/jotes","followers_url":"https://api.github.com/users/jotes/followers","following_url":"https://api.github.com/users/jotes/following{/other_user}","gists_url":"https://api.github.com/users/jotes/gists{/gist_id}","starred_url":"https://api.github.com/users/jotes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jotes/subscriptions","organizations_url":"https://api.github.com/users/jotes/orgs","repos_url":"https://api.github.com/users/jotes/repos","events_url":"https://api.github.com/users/jotes/events{/privacy}","received_events_url":"https://api.github.com/users/jotes/received_events","type":"User","site_admin":false},"repo":{"id":40921914,"name":"pontoon","full_name":"jotes/pontoon","owner":{"login":"jotes","id":8784972,"avatar_url":"https://avatars1.githubusercontent.com/u/8784972?v=3","gravatar_id":"","url":"https://api.github.com/users/jotes","html_url":"https://github.com/jotes","followers_url":"https://api.github.com/users/jotes/followers","following_url":"https://api.github.com/users/jotes/following{/other_user}","gists_url":"https://api.github.com/users/jotes/gists{/gist_id}","starred_url":"https://api.github.com/users/jotes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jotes/subscriptions","organizations_url":"https://api.github.com/users/jotes/orgs","repos_url":"https://api.github.com/users/jotes/repos","events_url":"https://api.github.com/users/jotes/events{/privacy}","received_events_url":"https://api.github.com/users/jotes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jotes/pontoon","description":"In-place localization tool","fork":true,"url":"https://api.github.com/repos/jotes/pontoon","forks_url":"https://api.github.com/repos/jotes/pontoon/forks","keys_url":"https://api.github.com/repos/jotes/pontoon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jotes/pontoon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jotes/pontoon/teams","hooks_url":"https://api.github.com/repos/jotes/pontoon/hooks","issue_events_url":"https://api.github.com/repos/jotes/pontoon/issues/events{/number}","events_url":"https://api.github.com/repos/jotes/pontoon/events","assignees_url":"https://api.github.com/repos/jotes/pontoon/assignees{/user}","branches_url":"https://api.github.com/repos/jotes/pontoon/branches{/branch}","tags_url":"https://api.github.com/repos/jotes/pontoon/tags","blobs_url":"https://api.github.com/repos/jotes/pontoon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jotes/pontoon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jotes/pontoon/git/refs{/sha}","trees_url":"https://api.github.com/repos/jotes/pontoon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jotes/pontoon/statuses/{sha}","languages_url":"https://api.github.com/repos/jotes/pontoon/languages","stargazers_url":"https://api.github.com/repos/jotes/pontoon/stargazers","contributors_url":"https://api.github.com/repos/jotes/pontoon/contributors","subscribers_url":"https://api.github.com/repos/jotes/pontoon/subscribers","subscription_url":"https://api.github.com/repos/jotes/pontoon/subscription","commits_url":"https://api.github.com/repos/jotes/pontoon/commits{/sha}","git_commits_url":"https://api.github.com/repos/jotes/pontoon/git/commits{/sha}","comments_url":"https://api.github.com/repos/jotes/pontoon/comments{/number}","issue_comment_url":"https://api.github.com/repos/jotes/pontoon/issues/comments{/number}","contents_url":"https://api.github.com/repos/jotes/pontoon/contents/{+path}","compare_url":"https://api.github.com/repos/jotes/pontoon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jotes/pontoon/merges","archive_url":"https://api.github.com/repos/jotes/pontoon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jotes/pontoon/downloads","issues_url":"https://api.github.com/repos/jotes/pontoon/issues{/number}","pulls_url":"https://api.github.com/repos/jotes/pontoon/pulls{/number}","milestones_url":"https://api.github.com/repos/jotes/pontoon/milestones{/number}","notifications_url":"https://api.github.com/repos/jotes/pontoon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jotes/pontoon/labels{/name}","releases_url":"https://api.github.com/repos/jotes/pontoon/releases{/id}","deployments_url":"https://api.github.com/repos/jotes/pontoon/deployments","created_at":"2015-08-17T19:18:45Z","updated_at":"2016-02-20T23:53:08Z","pushed_at":"2017-05-16T23:34:31Z","git_url":"git://github.com/jotes/pontoon.git","ssh_url":"git@github.com:jotes/pontoon.git","clone_url":"https://github.com/jotes/pontoon.git","svn_url":"https://github.com/jotes/pontoon","homepage":"https://pontoon.mozilla.org/","size":21215,"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,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"3455aaadaac6b7f1727676d76bc14e3750a55773","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars1.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":1385890,"name":"pontoon","full_name":"mozilla/pontoon","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars1.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/pontoon","description":"In-place localization tool","fork":false,"url":"https://api.github.com/repos/mozilla/pontoon","forks_url":"https://api.github.com/repos/mozilla/pontoon/forks","keys_url":"https://api.github.com/repos/mozilla/pontoon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/pontoon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/pontoon/teams","hooks_url":"https://api.github.com/repos/mozilla/pontoon/hooks","issue_events_url":"https://api.github.com/repos/mozilla/pontoon/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/pontoon/events","assignees_url":"https://api.github.com/repos/mozilla/pontoon/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/pontoon/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/pontoon/tags","blobs_url":"https://api.github.com/repos/mozilla/pontoon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/pontoon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/pontoon/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/pontoon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/pontoon/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/pontoon/languages","stargazers_url":"https://api.github.com/repos/mozilla/pontoon/stargazers","contributors_url":"https://api.github.com/repos/mozilla/pontoon/contributors","subscribers_url":"https://api.github.com/repos/mozilla/pontoon/subscribers","subscription_url":"https://api.github.com/repos/mozilla/pontoon/subscription","commits_url":"https://api.github.com/repos/mozilla/pontoon/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/pontoon/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/pontoon/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/pontoon/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/pontoon/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/pontoon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/pontoon/merges","archive_url":"https://api.github.com/repos/mozilla/pontoon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/pontoon/downloads","issues_url":"https://api.github.com/repos/mozilla/pontoon/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/pontoon/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/pontoon/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/pontoon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/pontoon/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/pontoon/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/pontoon/deployments","created_at":"2011-02-19T11:25:51Z","updated_at":"2017-05-12T14:28:41Z","pushed_at":"2017-05-16T23:34:33Z","git_url":"git://github.com/mozilla/pontoon.git","ssh_url":"git@github.com:mozilla/pontoon.git","clone_url":"https://github.com/mozilla/pontoon.git","svn_url":"https://github.com/mozilla/pontoon","homepage":"https://pontoon.mozilla.org/","size":21008,"stargazers_count":211,"watchers_count":211,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":5,"forks":63,"open_issues":5,"watchers":211,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/606"},"html":{"href":"https://github.com/mozilla/pontoon/pull/606"},"issue":{"href":"https://api.github.com/repos/mozilla/pontoon/issues/606"},"comments":{"href":"https://api.github.com/repos/mozilla/pontoon/issues/606/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/606/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/606/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/pontoon/statuses/fa052c0c28720ce261ddf01f58ca4b543f80b6e4"}}}}
{"actor":{"display_login":"mathjazz"}}