Index: packagerChrome.py |
=================================================================== |
--- a/packagerChrome.py |
+++ b/packagerChrome.py |
@@ -160,6 +160,12 @@ |
sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)), sourceFiles) |
files[file] = doRewrite(sourceFiles, args) |
+def toJson(data): |
+ return json.dumps( |
+ data, ensure_ascii=False, sort_keys=True, |
+ indent=2, separators=(',', ': ') |
+ ).encode('utf-8') + '\n' |
+ |
def importGeckoLocales(params, files): |
import localeTools |
@@ -261,8 +267,7 @@ |
except Exception, e: |
print 'Warning: error importing locale data from %s: %s' % (sourceFile, e) |
- files[targetFile] = json.dumps(data, ensure_ascii=False, sort_keys=True, |
- indent=2, separators=(',', ': ')).encode('utf-8') + '\n' |
+ files[targetFile] = toJson(data) |
if params['type'] == 'opera': |
# Opera has a slightly different locale mapping |
@@ -279,6 +284,23 @@ |
files[operaFile] = files[chromeFile] |
del files[chromeFile] |
+def fixMissingTranslations(files): |
+ # Chrome requires messages used in manifest.json to be given in all languages |
+ defaults = [] |
+ for name, info in json.loads(files['_locales/%s/messages.json' % defaultLocale]).iteritems(): |
+ if '__MSG_%s__' % name in files['manifest.json']: |
+ defaults.append((name, info)) |
Wladimir Palant
2014/03/13 15:21:45
This seems backwards, shouldn't we search for __MS
Sebastian Noack
2014/03/13 15:44:33
Done.
|
+ |
+ for filename in files: |
+ if not filename.startswith('_locales/') or not filename.endswith('/messages.json'): |
+ continue |
+ |
+ data = json.loads(files[filename]) |
+ for name, info in defaults: |
+ data.setdefault(name, info) |
+ |
+ files[filename] = toJson(data) |
+ |
def signBinary(zipdata, keyFile): |
import M2Crypto |
if not os.path.exists(keyFile): |
@@ -343,6 +365,8 @@ |
if metadata.has_section('import_locales'): |
importGeckoLocales(params, files) |
+ fixMissingTranslations(files) |
+ |
if devenv: |
files['devenvPoller__.js'] = createPoller(params) |