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

Side by Side Diff: localeTools.py

Issue 9257092: More build tools improvements (Closed)
Patch Set: Created Jan. 25, 2013, 10:22 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « localeSyncChrome.py ('k') | packager.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus build tools, 3 # This file is part of the Adblock Plus build tools,
4 # Copyright (C) 2006-2012 Eyeo GmbH 4 # Copyright (C) 2006-2012 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 file = codecs.open(path, 'wb', encoding='utf-8') 239 file = codecs.open(path, 'wb', encoding='utf-8')
240 for key, value in data.iteritems(): 240 for key, value in data.iteritems():
241 file.write(generateStringEntry(key, value['message'], path)) 241 file.write(generateStringEntry(key, value['message'], path))
242 file.close() 242 file.close()
243 243
244 def preprocessChromeLocale(path, metadata, isMaster): 244 def preprocessChromeLocale(path, metadata, isMaster):
245 fileHandle = codecs.open(path, 'rb', encoding='utf-8') 245 fileHandle = codecs.open(path, 'rb', encoding='utf-8')
246 data = json.load(fileHandle) 246 data = json.load(fileHandle)
247 fileHandle.close() 247 fileHandle.close()
248 248
249 # Remove synced keys, these don't need to be translated
250 if metadata.has_section('locale_sync'):
251 for file, stringIDs in metadata.items('locale_sync'):
252 for stringID in re.split(r'\s+', stringIDs):
253 if file == 'remove':
254 key = stringID
255 else:
256 key = re.sub(r'\..*', '', file) + '_' + re.sub(r'\W', '_', stringID)
257 if key in data:
258 del data[key]
259
260 for key, value in data.iteritems(): 249 for key, value in data.iteritems():
261 if isMaster: 250 if isMaster:
262 # Make sure the key name is listed in the description 251 # Make sure the key name is listed in the description
263 if "description" in value: 252 if "description" in value:
264 value["description"] = "%s: %s" % (key, value["description"]) 253 value["description"] = "%s: %s" % (key, value["description"])
265 else: 254 else:
266 value["description"] = key 255 value["description"] = key
267 else: 256 else:
268 # Delete description from translations 257 # Delete description from translations
269 if "description" in value: 258 if "description" in value:
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 440
452 # Remove any extra files 441 # Remove any extra files
453 for dir, files in dirs.iteritems(): 442 for dir, files in dirs.iteritems():
454 baseDir = os.path.join(localesDir, dir) 443 baseDir = os.path.join(localesDir, dir)
455 if not os.path.exists(baseDir): 444 if not os.path.exists(baseDir):
456 continue 445 continue
457 for file in os.listdir(baseDir): 446 for file in os.listdir(baseDir):
458 path = os.path.join(baseDir, file) 447 path = os.path.join(baseDir, file)
459 if os.path.isfile(path) and (file.endswith('.json') or file.endswith('.pro perties') or file.endswith('.dtd')) and not file in files: 448 if os.path.isfile(path) and (file.endswith('.json') or file.endswith('.pro perties') or file.endswith('.dtd')) and not file in files:
460 os.remove(path) 449 os.remove(path)
OLDNEW
« no previous file with comments | « localeSyncChrome.py ('k') | packager.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld