Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: localeTools.py

Issue 29372826: Issue 4836 - Have the setuptrans command use the current Crowdin API (Closed)
Patch Set: Created Jan. 24, 2017, 10:17 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: localeTools.py
diff --git a/localeTools.py b/localeTools.py
index e97147d48f6b980636ce0a69096a0c92f01b2877..f9e8d830a927cb7b932f5851298c9f28462069ef 100644
--- a/localeTools.py
+++ b/localeTools.py
@@ -318,8 +318,10 @@ def setupTranslations(localeConfig, projectName, key):
locales.add(mapLocale('BCP-47', match2.group(1)))
allowed = set()
- allowedLocales = urllib2.urlopen('http://crowdin.net/page/language-codes').read()
- for match in re.finditer(r'<tr>\s*<td\b[^<>]*>([\w\-]+)</td>', allowedLocales, re.S):
+ allowedLocales = urllib2.urlopen(
+ 'https://crowdin.com/languages/languages_list?callback=foo'
Wladimir Palant 2017/01/24 11:36:23 Please use https://crowdin.com/languages/languages
kzar 2017/01/25 03:45:04 Ah cool, didn't think to try that. Done.
+ ).read()
+ for match in re.finditer(r'"code"\s*:\s*"([\w\-]+)"', allowedLocales, re.S):
Wladimir Palant 2017/01/24 11:36:23 Please don't use regular expressions to parse JSON
kzar 2017/01/25 03:45:04 (I would have already if I had figured out the way
allowed.add(match.group(1))
if not allowed.issuperset(locales):
print "Warning, following locales aren't allowed by server: " + ', '.join(locales - allowed)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld