| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
| 2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | 4 |
| 5 import errno | 5 import errno |
| 6 import io | 6 import io |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 from StringIO import StringIO | 10 from StringIO import StringIO |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 value = value[0:index] + value[index + 1:] | 211 value = value[0:index] + value[index + 1:] |
| 212 | 212 |
| 213 data[key] = {'message': value} | 213 data[key] = {'message': value} |
| 214 | 214 |
| 215 | 215 |
| 216 def import_locales(params, files): | 216 def import_locales(params, files): |
| 217 for item in params['metadata'].items('import_locales'): | 217 for item in params['metadata'].items('import_locales'): |
| 218 filename, keys = item | 218 filename, keys = item |
| 219 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), | 219 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), |
| 220 *filename.split('/'))): | 220 *filename.split('/'))): |
| 221 locale = sourceFile.split(os.path.sep)[-2].replace('-', '_') | 221 parts = sourceFile.split(os.path.sep) |
|
Sebastian Noack
2017/10/05 19:01:43
Replacing dashes with underscore here is only nece
|
Sebastian Noack
2017/10/05 20:58:38
I just noticed that the variable "parts" is used b
tlucas
2017/10/06 08:53:53
Acknowledged.
|
| 222 locale = parts[-2].replace('-', '_') | |
| 222 targetFile = os.path.join('_locales', locale, 'messages.json') | 223 targetFile = os.path.join('_locales', locale, 'messages.json') |
| 223 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) | 224 data = json.loads(files.get(targetFile, '{}').decode('utf-8')) |
| 224 | 225 |
| 225 try: | 226 try: |
| 226 # The WebExtensions (.json) and Gecko format provide | 227 # The WebExtensions (.json) and Gecko format provide |
| 227 # translations differently and/or provide additional | 228 # translations differently and/or provide additional |
| 228 # information like e.g. "placeholders". We want to adhere to | 229 # information like e.g. "placeholders". We want to adhere to |
| 229 # that and preserve the addtional info. | 230 # that and preserve the addtional info. |
| 230 if sourceFile.endswith('.json'): | 231 if sourceFile.endswith('.json'): |
| 231 with io.open(sourceFile, 'r', encoding='utf-8') as handle: | 232 with io.open(sourceFile, 'r', encoding='utf-8') as handle: |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 params, 'testIndex.html.tmpl', ('general', 'testScripts') | 402 params, 'testIndex.html.tmpl', ('general', 'testScripts') |
| 402 ) | 403 ) |
| 403 | 404 |
| 404 zipdata = files.zipToString() | 405 zipdata = files.zipToString() |
| 405 signature = None | 406 signature = None |
| 406 pubkey = None | 407 pubkey = None |
| 407 if keyFile != None: | 408 if keyFile != None: |
| 408 signature = signBinary(zipdata, keyFile) | 409 signature = signBinary(zipdata, keyFile) |
| 409 pubkey = getPublicKey(keyFile) | 410 pubkey = getPublicKey(keyFile) |
| 410 writePackage(outFile, pubkey, signature, zipdata) | 411 writePackage(outFile, pubkey, signature, zipdata) |
| LEFT | RIGHT |