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

Unified Diff: packagerChrome.py

Issue 29561557: Issue 5763 - Target languages supported by Firefox (Closed)
Patch Set: Created Oct. 1, 2017, 5:12 p.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
« localeTools.py ('K') | « localeTools.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packagerChrome.py
===================================================================
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -296,10 +296,7 @@
return text[:length_limit - 1].rstrip() + u'\u2026'
-def fixTranslationsForCWS(files):
- # Chrome Web Store requires messages used in manifest.json to be present in
- # all languages. It also enforces length limits for extension names and
- # descriptions.
+def fixTranslationsForChrome(files):
tlucas 2017/10/02 09:25:43 nit: when changing a function's name the new name
Sebastian Noack 2017/10/02 23:01:33 Done.
defaults = {}
data = json.loads(files['_locales/%s/messages.json' % defaultLocale])
for match in re.finditer(r'__MSG_(\S+)__', files['manifest.json']):
@@ -313,17 +310,29 @@
if match:
limits[match.group(1)] = limit
- for filename in files:
- if not filename.startswith('_locales/') or not filename.endswith('/messages.json'):
- continue
+ for path in list(files):
+ match = re.search(r'^_locales/(?:es_(AR|CL|(MX))|[^/]+)/(.*)', path)
+ if match:
Vasily Kuznetsov 2017/10/02 21:13:32 This loop with a regexp search and then `if match`
Sebastian Noack 2017/10/02 23:01:33 The reason why I didn't bail out, but went for the
+ isLatAm, isMexican, filename = match.groups()
Vasily Kuznetsov 2017/10/02 21:13:32 While PEP8 is annoyingly non-specific with regards
Sebastian Noack 2017/10/02 23:01:33 Yeah, this should be lowercase with underscores. D
- data = json.loads(files[filename])
- for name, info in defaults.iteritems():
- data.setdefault(name, info)
- for name, limit in limits.iteritems():
- if name in data:
- data[name]['message'] = truncate(data[name]['message'], limit)
- files[filename] = toJson(data)
+ # The Chrome Web Store requires messages used in manifest.json to be
tlucas 2017/10/02 09:25:43 nit: this line is 1 character too long
Sebastian Noack 2017/10/02 23:01:33 Done.
+ # present in all languages, and enforces length limits on extension
+ # name and description.
+ if filename == 'messages.json':
+ data = json.loads(files[path])
+ for name, info in defaults.iteritems():
+ data.setdefault(name, info)
+ for name, limit in limits.iteritems():
+ info = data.get(name)
+ if info:
+ info['message'] = truncate(info['message'], limit)
+ files[path] = toJson(data)
+
+ # Chrome combines Latin American dialects of Spanish into es-419.
+ if isLatAm:
+ data = files.pop(path)
+ if isMexican:
+ files['_locales/es_419/' + filename] = data
def signBinary(zipdata, keyFile):
@@ -403,7 +412,7 @@
files['manifest.json'] = createManifest(params, files)
if type == 'chrome':
- fixTranslationsForCWS(files)
+ fixTranslationsForChrome(files)
if devenv:
import buildtools
« localeTools.py ('K') | « localeTools.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld