Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This Source Code Form is subject to the terms of the Mozilla Public | 3 # This Source Code Form is subject to the terms of the Mozilla Public |
4 # License, v. 2.0. If a copy of the MPL was not distributed with this | 4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
6 | 6 |
7 import sys | 7 import sys |
8 import os | 8 import os |
9 import re | 9 import re |
10 import json | 10 import json |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 | 160 |
161 def toJson(data): | 161 def toJson(data): |
162 return json.dumps( | 162 return json.dumps( |
163 data, ensure_ascii=False, sort_keys=True, | 163 data, ensure_ascii=False, sort_keys=True, |
164 indent=2, separators=(',', ': ') | 164 indent=2, separators=(',', ': ') |
165 ).encode('utf-8') + '\n' | 165 ).encode('utf-8') + '\n' |
166 | 166 |
167 def importGeckoLocales(params, files): | 167 def importGeckoLocales(params, files): |
168 import localeTools | 168 import localeTools |
169 | 169 |
170 # FIXME: localeTools doesn't use real Chrome locales, it uses dash as | |
171 # separator instead. | |
172 convert_locale_code = lambda code: code.replace('-', '_') | |
173 | |
170 # We need to map Chrome locales to Gecko locales. Start by mapping Chrome | 174 # We need to map Chrome locales to Gecko locales. Start by mapping Chrome |
171 # locales to themselves, merely with the minus sign as separator. | 175 # locales to themselves, merely with the dash as separator. |
172 locale_mapping = {l.replace('-', '_'): l for l in localeTools.chromeLocales} | 176 locale_mapping = {convert_locale_code(l): l for l in localeTools.chromeLocales } |
173 | 177 |
174 # Convert values to Crowdin locales first (use Chrome => Crowdin mapping). | 178 # Convert values to Crowdin locales first (use Chrome => Crowdin mapping). |
175 for chrome_locale, crowdin_locale in localeTools.langMappingChrome.iteritems() : | 179 for chrome_locale, crowdin_locale in localeTools.langMappingChrome.iteritems() : |
176 locale_mapping[chrome_locale.replace('-', '_')] = crowdin_locale | 180 locale_mapping[convert_locale_code(chrome_locale)] = crowdin_locale |
Sebastian Noack
2014/12/17 14:11:46
I'd rather not duplicate the logic replacing the d
Wladimir Palant
2014/12/17 14:59:33
Done.
| |
177 | 181 |
178 # Now convert values to Gecko locales (use Gecko => Crowdin mapping). | 182 # Now convert values to Gecko locales (use Gecko => Crowdin mapping). |
179 reverse_mapping = {v: k for k, v in locale_mapping.iteritems()} | 183 reverse_mapping = {v: k for k, v in locale_mapping.iteritems()} |
180 for gecko_locale, crowdin_locale in localeTools.langMappingGecko.iteritems(): | 184 for gecko_locale, crowdin_locale in localeTools.langMappingGecko.iteritems(): |
181 if crowdin_locale in reverse_mapping: | 185 if crowdin_locale in reverse_mapping: |
182 locale_mapping[reverse_mapping[crowdin_locale]] = gecko_locale | 186 locale_mapping[reverse_mapping[crowdin_locale]] = gecko_locale |
183 | 187 |
184 for target, source in locale_mapping.iteritems(): | 188 for target, source in locale_mapping.iteritems(): |
185 targetFile = '_locales/%s/messages.json' % target | 189 targetFile = '_locales/%s/messages.json' % target |
186 if not targetFile in files: | 190 if not targetFile in files: |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 'lib/info.js' not in files): | 372 'lib/info.js' not in files): |
369 files['lib/info.js'] = createInfoModule(params) | 373 files['lib/info.js'] = createInfoModule(params) |
370 | 374 |
371 zipdata = files.zipToString() | 375 zipdata = files.zipToString() |
372 signature = None | 376 signature = None |
373 pubkey = None | 377 pubkey = None |
374 if keyFile != None: | 378 if keyFile != None: |
375 signature = signBinary(zipdata, keyFile) | 379 signature = signBinary(zipdata, keyFile) |
376 pubkey = getPublicKey(keyFile) | 380 pubkey = getPublicKey(keyFile) |
377 writePackage(outFile, pubkey, signature, zipdata) | 381 writePackage(outFile, pubkey, signature, zipdata) |
LEFT | RIGHT |