{"action":"created","comment":{"url":"https://api.github.com/repos/mapsme/omim/pulls/comments/63725953","id":63725953,"diff_hunk":"@@ -0,0 +1,159 @@\n+#! /usr/bin/env python\n+# -*- coding: utf-8 -*-\n+from __future__ import print_function\n+from collections import namedtuple\n+\n+import re\n+\n+TransAndKey = namedtuple(\"TransAndKey\", \"translation, key\")\n+\n+\n+translation = re.compile(r'([a-z]{2}|zh-Han[st])\\s*=\\s*.*$', re.S | re.MULTILINE)\n+\n+ITUNES_LANGS = ['en', 'ru', 'ar', 'cs', 'da', 'nl', 'fi', 'fr', 'de', 'hu', 'id', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ro', 'sl', 'es', 'sv', 'th', 'tr', 'uk', 'vi', 'zh-Hans', 'zh-Hant']\n+\n+\n+class StringsTxt:\n+\n+    def __init__(self):\n+        self.translations = {} # dict<key, dict<lang, translation>>\n+        self.comments_and_tags = {}\n+        self.with_english = []\n+        self.current_key = \"\"\n+        self.all_langs = set()\n+        self.duplicates = {} # dict<lang, TransAndKey>\n+        self.keys_in_order = []\n+        self._read_file()\n+\n+\n+    def _read_file(self):\n+        with open(\"../strings.txt\") as strings:\n+            for line in strings:\n+                line = line.strip()\n+                if not line: continue\n+                if line.startswith(\"[[\"):\n+                    self.keys_in_order.append(line)\n+                    continue\n+                if line.startswith(\"[\"):\n+                    if line in self.translations:\n+                        print(\"Duplicate key {}\".format(line))\n+                        continue\n+                    self.translations[line] = {}\n+                    current_key = line\n+                    self.keys_in_order.append(current_key)\n+\n+                if translation.match(line):\n+                    lang, tran = self.lang_and_translation(line)\n+                    self._append_to_translations(current_key, lang, tran)\n+\n+                    self.all_langs.add(lang)\n+                    if line.startswith(\"en = \"):\n+                        self.with_english.append(current_key)\n+                    continue\n+\n+                if line.startswith(\"comment\") or line.startswith(\"tags\"):\n+                    if current_key not in self.comments_and_tags:\n+                        self.comments_and_tags[current_key] = {}\n+\n+                    lang, value = self.lang_and_translation(line)\n+                    self.comments_and_tags[current_key][lang] = value\n+                    continue\n+\n+\n+    def print_statistics(self):\n+        for key in self.translations:\n+            print(\"{}\\t{}\".format(key, len(self.translations[key])))\n+\n+        print(\"\\n\\n========================================\\n\\nDuplicates: \")\n+        for lang, trans_and_keys in self.duplicates.items():\n+            print(\"== {} ==\".format(lang))\n+            last_one = \"\"\n+            for tr in trans_and_keys:\n+                if last_one != tr.translation:\n+                    print(\"\\n\")\n+                last_one = tr.translation\n+                print(\"{} : {}\".format(tr.key, tr.translation))\n+\n+\n+    def _append_to_translations(self, key, lang, tran):\n+        if key not in self.translations:\n+            self.translations[key] = {}\n+        self.translations[key][lang] = tran\n+\n+\n+    def process_string(self, string):\n+        return str.strip(string).replace(\"...\", \"…\")\n+\n+\n+    def lang_and_translation(self, line):\n+        return tuple(map(self.process_string, line.split(\"=\")))\n+\n+\n+    def find_duplicates(self):\n+        possible_duplicates = set()\n+        for lang in self.all_langs:\n+            trans_for_lang = []\n+            for key, tran in self.translations.items(): # (tran = dict<lang, translation>)\n+                if lang not in tran:\n+                    continue\n+                trans_for_lang.append(TransAndKey(tran[lang], key))\n+\n+            trans_for_lang.sort()\n+            last_tran = TransAndKey(\"\", \"\")\n+            for t in trans_for_lang:\n+                if t.translation == last_tran.translation:\n+                    possible_duplicates.add(last_tran)\n+                    possible_duplicates.add(t)\n+                else:\n+                    last_tran = t\n+\n+            self.duplicates[lang] = sorted(list(possible_duplicates))\n+\n+\n+    def find_missing_itunes_langs(self):\n+        print(\"\\n\\n======================================\\n\\nMissing translations for iTunes languages:\")\n+        for key, tran in self.translations.items():\n+            langs = set(tran.keys())\n+            missing_langs = set(ITUNES_LANGS) - langs\n+            if missing_langs:\n+                print(\"Missing languages for key {}\".format(key))\n+                print(\", \".join(missing_langs) + \"\\n\")","path":"tools/find_untranslated_strings.py","position":120,"original_position":120,"commit_id":"4e21f7ce3241623277280611424627a5724018e1","original_commit_id":"4e21f7ce3241623277280611424627a5724018e1","user":{"login":"therearesomewhocallmetim","id":14867234,"avatar_url":"https://avatars.githubusercontent.com/u/14867234?v=3","gravatar_id":"","url":"https://api.github.com/users/therearesomewhocallmetim","html_url":"https://github.com/therearesomewhocallmetim","followers_url":"https://api.github.com/users/therearesomewhocallmetim/followers","following_url":"https://api.github.com/users/therearesomewhocallmetim/following{/other_user}","gists_url":"https://api.github.com/users/therearesomewhocallmetim/gists{/gist_id}","starred_url":"https://api.github.com/users/therearesomewhocallmetim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/therearesomewhocallmetim/subscriptions","organizations_url":"https://api.github.com/users/therearesomewhocallmetim/orgs","repos_url":"https://api.github.com/users/therearesomewhocallmetim/repos","events_url":"https://api.github.com/users/therearesomewhocallmetim/events{/privacy}","received_events_url":"https://api.github.com/users/therearesomewhocallmetim/received_events","type":"User","site_admin":false},"body":"По-моему, \r\n\r\n```\r\nMissing languages for key [editor_place_doesnt_exist]\r\nsl, pt, zh-Hant\r\n\r\nMissing languages for key [duration_1_hour]\r\nsl\r\n\r\nMissing languages for key [subscribe_me_body]\r\nsl\r\n\r\nMissing languages for key [pro_version_is_free_today]\r\nvi, nb, sl, fi, ro, id\r\n```\r\n\r\nудобнее читать, чем \r\n\r\n```\r\nMissing languages for key [editor_place_doesnt_exist]\r\nsl, pt, zh-Hant\r\nMissing languages for key [duration_1_hour]\r\nsl\r\nMissing languages for key [subscribe_me_body]\r\nsl\r\nMissing languages for key [pro_version_is_free_today]\r\nvi, nb, sl, fi, ro, id\r\n```\r\n\r\nСделаю чуть по-другому","created_at":"2016-05-18T15:29:47Z","updated_at":"2016-05-18T15:29:47Z","html_url":"https://github.com/mapsme/omim/pull/3263#discussion_r63725953","pull_request_url":"https://api.github.com/repos/mapsme/omim/pulls/3263","_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments/63725953"},"html":{"href":"https://github.com/mapsme/omim/pull/3263#discussion_r63725953"},"pull_request":{"href":"https://api.github.com/repos/mapsme/omim/pulls/3263"}}},"pull_request":{"url":"https://api.github.com/repos/mapsme/omim/pulls/3263","id":70536972,"html_url":"https://github.com/mapsme/omim/pull/3263","diff_url":"https://github.com/mapsme/omim/pull/3263.diff","patch_url":"https://github.com/mapsme/omim/pull/3263.patch","issue_url":"https://api.github.com/repos/mapsme/omim/issues/3263","number":3263,"state":"open","locked":false,"title":"Wrote a script for analyzing strings.txt (instead of Alex)","user":{"login":"therearesomewhocallmetim","id":14867234,"avatar_url":"https://avatars.githubusercontent.com/u/14867234?v=3","gravatar_id":"","url":"https://api.github.com/users/therearesomewhocallmetim","html_url":"https://github.com/therearesomewhocallmetim","followers_url":"https://api.github.com/users/therearesomewhocallmetim/followers","following_url":"https://api.github.com/users/therearesomewhocallmetim/following{/other_user}","gists_url":"https://api.github.com/users/therearesomewhocallmetim/gists{/gist_id}","starred_url":"https://api.github.com/users/therearesomewhocallmetim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/therearesomewhocallmetim/subscriptions","organizations_url":"https://api.github.com/users/therearesomewhocallmetim/orgs","repos_url":"https://api.github.com/users/therearesomewhocallmetim/repos","events_url":"https://api.github.com/users/therearesomewhocallmetim/events{/privacy}","received_events_url":"https://api.github.com/users/therearesomewhocallmetim/received_events","type":"User","site_admin":false},"body":"* Autoformat (incl. blank lines, spaces at the beginning of the lines, no spaces at the end of the lines, ... -> …, more to follow)\r\n* Find duplicate translations (identical translations for different keys for the same language)\r\n* Find missing translations for the languages declared as supported (taken from the AppStore description)","created_at":"2016-05-18T14:23:34Z","updated_at":"2016-05-18T15:29:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e2dee03f061672edd537d11540e509e3b93160e7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mapsme/omim/pulls/3263/commits","review_comments_url":"https://api.github.com/repos/mapsme/omim/pulls/3263/comments","review_comment_url":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapsme/omim/issues/3263/comments","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/4e21f7ce3241623277280611424627a5724018e1","head":{"label":"therearesomewhocallmetim:strings_txt_duplicates","ref":"strings_txt_duplicates","sha":"4e21f7ce3241623277280611424627a5724018e1","user":{"login":"therearesomewhocallmetim","id":14867234,"avatar_url":"https://avatars.githubusercontent.com/u/14867234?v=3","gravatar_id":"","url":"https://api.github.com/users/therearesomewhocallmetim","html_url":"https://github.com/therearesomewhocallmetim","followers_url":"https://api.github.com/users/therearesomewhocallmetim/followers","following_url":"https://api.github.com/users/therearesomewhocallmetim/following{/other_user}","gists_url":"https://api.github.com/users/therearesomewhocallmetim/gists{/gist_id}","starred_url":"https://api.github.com/users/therearesomewhocallmetim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/therearesomewhocallmetim/subscriptions","organizations_url":"https://api.github.com/users/therearesomewhocallmetim/orgs","repos_url":"https://api.github.com/users/therearesomewhocallmetim/repos","events_url":"https://api.github.com/users/therearesomewhocallmetim/events{/privacy}","received_events_url":"https://api.github.com/users/therearesomewhocallmetim/received_events","type":"User","site_admin":false},"repo":{"id":43429309,"name":"omim","full_name":"therearesomewhocallmetim/omim","owner":{"login":"therearesomewhocallmetim","id":14867234,"avatar_url":"https://avatars.githubusercontent.com/u/14867234?v=3","gravatar_id":"","url":"https://api.github.com/users/therearesomewhocallmetim","html_url":"https://github.com/therearesomewhocallmetim","followers_url":"https://api.github.com/users/therearesomewhocallmetim/followers","following_url":"https://api.github.com/users/therearesomewhocallmetim/following{/other_user}","gists_url":"https://api.github.com/users/therearesomewhocallmetim/gists{/gist_id}","starred_url":"https://api.github.com/users/therearesomewhocallmetim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/therearesomewhocallmetim/subscriptions","organizations_url":"https://api.github.com/users/therearesomewhocallmetim/orgs","repos_url":"https://api.github.com/users/therearesomewhocallmetim/repos","events_url":"https://api.github.com/users/therearesomewhocallmetim/events{/privacy}","received_events_url":"https://api.github.com/users/therearesomewhocallmetim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/therearesomewhocallmetim/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":true,"url":"https://api.github.com/repos/therearesomewhocallmetim/omim","forks_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/forks","keys_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/teams","hooks_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/hooks","issue_events_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/issues/events{/number}","events_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/events","assignees_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/assignees{/user}","branches_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/branches{/branch}","tags_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/tags","blobs_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/languages","stargazers_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/stargazers","contributors_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/contributors","subscribers_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/subscribers","subscription_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/subscription","commits_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/contents/{+path}","compare_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/merges","archive_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/downloads","issues_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/issues{/number}","pulls_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/labels{/name}","releases_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/releases{/id}","deployments_url":"https://api.github.com/repos/therearesomewhocallmetim/omim/deployments","created_at":"2015-09-30T11:33:11Z","updated_at":"2015-09-30T11:35:20Z","pushed_at":"2016-05-18T14:22:18Z","git_url":"git://github.com/therearesomewhocallmetim/omim.git","ssh_url":"git@github.com:therearesomewhocallmetim/omim.git","clone_url":"https://github.com/therearesomewhocallmetim/omim.git","svn_url":"https://github.com/therearesomewhocallmetim/omim","homepage":null,"size":2370803,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mapsme:master","ref":"master","sha":"0359fd1c86eb86ebfd3358c955437c4f78eeee54","user":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"repo":{"id":42798033,"name":"omim","full_name":"mapsme/omim","owner":{"login":"mapsme","id":14185141,"avatar_url":"https://avatars.githubusercontent.com/u/14185141?v=3","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapsme/omim","description":"MAPS.ME - Offline OpenStreetMap maps for iOS/Android/Mac/Linux/Windows","fork":false,"url":"https://api.github.com/repos/mapsme/omim","forks_url":"https://api.github.com/repos/mapsme/omim/forks","keys_url":"https://api.github.com/repos/mapsme/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapsme/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapsme/omim/teams","hooks_url":"https://api.github.com/repos/mapsme/omim/hooks","issue_events_url":"https://api.github.com/repos/mapsme/omim/issues/events{/number}","events_url":"https://api.github.com/repos/mapsme/omim/events","assignees_url":"https://api.github.com/repos/mapsme/omim/assignees{/user}","branches_url":"https://api.github.com/repos/mapsme/omim/branches{/branch}","tags_url":"https://api.github.com/repos/mapsme/omim/tags","blobs_url":"https://api.github.com/repos/mapsme/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapsme/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapsme/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapsme/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/mapsme/omim/languages","stargazers_url":"https://api.github.com/repos/mapsme/omim/stargazers","contributors_url":"https://api.github.com/repos/mapsme/omim/contributors","subscribers_url":"https://api.github.com/repos/mapsme/omim/subscribers","subscription_url":"https://api.github.com/repos/mapsme/omim/subscription","commits_url":"https://api.github.com/repos/mapsme/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapsme/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapsme/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapsme/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapsme/omim/contents/{+path}","compare_url":"https://api.github.com/repos/mapsme/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapsme/omim/merges","archive_url":"https://api.github.com/repos/mapsme/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapsme/omim/downloads","issues_url":"https://api.github.com/repos/mapsme/omim/issues{/number}","pulls_url":"https://api.github.com/repos/mapsme/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/mapsme/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/mapsme/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapsme/omim/labels{/name}","releases_url":"https://api.github.com/repos/mapsme/omim/releases{/id}","deployments_url":"https://api.github.com/repos/mapsme/omim/deployments","created_at":"2015-09-20T02:57:13Z","updated_at":"2016-05-17T21:14:19Z","pushed_at":"2016-05-18T15:15:37Z","git_url":"git://github.com/mapsme/omim.git","ssh_url":"git@github.com:mapsme/omim.git","clone_url":"https://github.com/mapsme/omim.git","svn_url":"https://github.com/mapsme/omim","homepage":null,"size":2451318,"stargazers_count":1773,"watchers_count":1773,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":272,"mirror_url":null,"open_issues_count":167,"forks":272,"open_issues":167,"watchers":1773,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/3263"},"html":{"href":"https://github.com/mapsme/omim/pull/3263"},"issue":{"href":"https://api.github.com/repos/mapsme/omim/issues/3263"},"comments":{"href":"https://api.github.com/repos/mapsme/omim/issues/3263/comments"},"review_comments":{"href":"https://api.github.com/repos/mapsme/omim/pulls/3263/comments"},"review_comment":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapsme/omim/pulls/3263/commits"},"statuses":{"href":"https://api.github.com/repos/mapsme/omim/statuses/4e21f7ce3241623277280611424627a5724018e1"}}}}