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

Side by Side Diff: localeTools.py

Issue 29562614: Issue 5752 - Removing safari support (Closed)
Patch Set: Rebasing, removing additional files Created Oct. 4, 2017, 12:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 re 5 import re
6 import os 6 import os
7 import sys 7 import sys
8 import codecs 8 import codecs
9 import json 9 import json
10 import urlparse 10 import urlparse
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 locales.add(match.group(1)) 119 locales.add(match.group(1))
120 120
121 # We don't translate indvidual dialects of languages 121 # We don't translate indvidual dialects of languages
122 # other than English, Spanish, Portuguese and Chinese. 122 # other than English, Spanish, Portuguese and Chinese.
123 for locale in list(locales): 123 for locale in list(locales):
124 prefix = locale.split('-')[0] 124 prefix = locale.split('-')[0]
125 if prefix not in {'en', 'es', 'pt', 'zh'}: 125 if prefix not in {'en', 'es', 'pt', 'zh'}:
126 locales.remove(locale) 126 locales.remove(locale)
127 locales.add(prefix) 127 locales.add(prefix)
128 128
129 # Add languages with existing translations. 129 # Add languages with existing translations.
130 locales.update(localeConfig['locales']) 130 locales.update(localeConfig['locales'])
131 131
132 # Don't add the language we translate from as target translation. 132 # Don't add the language we translate from as target translation.
133 locales.remove(localeConfig['default_locale'].replace('_', '-')) 133 locales.remove(localeConfig['default_locale'].replace('_', '-'))
134 134
135 # Convert to locales understood by Crowdin. 135 # Convert to locales understood by Crowdin.
136 locales = {CROWDIN_LANG_MAPPING.get(locale, locale) for locale in locales} 136 locales = {CROWDIN_LANG_MAPPING.get(locale, locale) for locale in locales}
137 allowed = {locale['crowdin_code'] for locale in 137 allowed = {locale['crowdin_code'] for locale in
138 crowdin_request(projectName, 'supported-languages', key)} 138 crowdin_request(projectName, 'supported-languages', key)}
139 if not allowed.issuperset(locales): 139 if not allowed.issuperset(locales):
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 # Remove any extra files 290 # Remove any extra files
291 for dir, files in dirs.iteritems(): 291 for dir, files in dirs.iteritems():
292 baseDir = os.path.join(localeConfig['base_path'], dir) 292 baseDir = os.path.join(localeConfig['base_path'], dir)
293 if not os.path.exists(baseDir): 293 if not os.path.exists(baseDir):
294 continue 294 continue
295 for file in os.listdir(baseDir): 295 for file in os.listdir(baseDir):
296 path = os.path.join(baseDir, file) 296 path = os.path.join(baseDir, file)
297 valid_extension = file.endswith('.json') 297 valid_extension = file.endswith('.json')
298 if os.path.isfile(path) and valid_extension and not file in files: 298 if os.path.isfile(path) and valid_extension and not file in files:
299 os.remove(path) 299 os.remove(path)
OLDNEW

Powered by Google App Engine
This is Rietveld