Index: packagerChrome.py |
=================================================================== |
--- a/packagerChrome.py |
+++ b/packagerChrome.py |
@@ -224,12 +224,12 @@ |
locale_mapping = {convert_locale_code(l): l for l in localeTools.chromeLocales} |
# Convert values to Crowdin locales first (use Chrome => Crowdin mapping). |
- for chrome_locale, crowdin_locale in localeTools.langMappingChrome.iteritems(): |
+ for chrome_locale, crowdin_locale in localeTools.CROWDIN_LANG_MAPPING.iteritems(): |
locale_mapping[convert_locale_code(chrome_locale)] = crowdin_locale |
# Now convert values to Gecko locales (use Gecko => Crowdin mapping). |
reverse_mapping = {v: k for k, v in locale_mapping.iteritems()} |
- for gecko_locale, crowdin_locale in localeTools.langMappingGecko.iteritems(): |
+ for gecko_locale, crowdin_locale in localeTools.CROWDIN_LANG_MAPPING.iteritems(): |
if crowdin_locale in reverse_mapping: |
locale_mapping[reverse_mapping[crowdin_locale]] = gecko_locale |
@@ -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 fix_translations_for_chrome(files): |
defaults = {} |
data = json.loads(files['_locales/%s/messages.json' % defaultLocale]) |
for match in re.finditer(r'__MSG_(\S+)__', files['manifest.json']): |
@@ -313,17 +310,30 @@ |
if match: |
limits[match.group(1)] = limit |
- for filename in files: |
- if not filename.startswith('_locales/') or not filename.endswith('/messages.json'): |
+ for path in list(files): |
+ match = re.search(r'^_locales/(?:es_(AR|CL|(MX))|[^/]+)/(.*)', path) |
+ if not match: |
continue |
- 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 present in all languages, and enforces length limits on |
+ # extension name and description. |
+ is_latam, is_mexican, filename = match.groups() |
+ 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 is_latam: |
+ data = files.pop(path) |
+ if is_mexican: |
+ files['_locales/es_419/' + filename] = data |
def signBinary(zipdata, keyFile): |
@@ -403,7 +413,7 @@ |
files['manifest.json'] = createManifest(params, files) |
if type == 'chrome': |
- fixTranslationsForCWS(files) |
+ fix_translations_for_chrome(files) |
if devenv: |
import buildtools |