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

Delta Between Two Patch Sets: cms/utils.py

Issue 5694103719247872: Issue 2133 - Allow to specify default translation inline in pages rather than in a separate file (Closed)
Left Patch Set: Created March 12, 2015, 7:34 p.m.
Right Patch Set: Addressed comments Created March 12, 2015, 8:56 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « cms/sources.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 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 30 matching lines...) Expand all
41 try: 41 try:
42 converter = converters[format](params) 42 converter = converters[format](params)
43 except KeyError: 43 except KeyError:
44 raise Exception("Page %s uses unknown format %s" % (page, format)) 44 raise Exception("Page %s uses unknown format %s" % (page, format))
45 45
46 # Note: The converter might change some parameters so we can only read in 46 # Note: The converter might change some parameters so we can only read in
47 # template data here. 47 # template data here.
48 params["templatedata"] = source.read_template(params["template"]) 48 params["templatedata"] = source.read_template(params["template"])
49 template_converter = TemplateConverter(params, key="templatedata") 49 template_converter = TemplateConverter(params, key="templatedata")
50 50
51 params["defaultlocale"] = params["config"].get("general", "defaultlocale") 51 defaultlocale = params["config"].get("general", "defaultlocale")
52 params["defaultlocale"] = defaultlocale
52 53
53 params["available_locales"] = [ 54 locales = [
54 locale 55 locale
55 for locale in source.list_locales() 56 for locale in source.list_locales()
56 if source.has_locale(locale, localefile) 57 if source.has_locale(locale, localefile)
57 ] 58 ]
58 if params["defaultlocale"] not in params["available_locales"]: 59 if defaultlocale not in locales:
59 params["available_locales"].append(params["defaultlocale"]) 60 locales.append(defaultlocale)
60 params["available_locales"].sort() 61 locales.sort()
Sebastian Noack 2015/03/12 20:33:46 Four inline lookups for "available_locales" and th
Wladimir Palant 2015/03/12 20:57:02 Not sure it really makes the code better here but
Sebastian Noack 2015/03/12 21:08:19 Much better. Thanks.
62 params["available_locales"] = locales
61 63
62 params["head"], params["body"] = converter() 64 params["head"], params["body"] = converter()
63 return template_converter() 65 return template_converter()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld