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

Delta Between Two Patch Sets: cms/utils.py

Issue 29317015: Issue 2625 - [cms] Crowdin synchronisation script (Closed)
Left Patch Set: Created June 15, 2015, 2:12 p.m.
Right Patch Set: Give query_params a default value Created July 16, 2015, 12:47 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,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 from cms.converters import converters, TemplateConverter 18 from cms.converters import converters, TemplateConverter
19 19
20 def get_page_params(source, locale, page, format=None, site_url_override=None): 20 def get_page_params(source, locale, page, format=None, site_url_override=None,
21 localized_string_callback=None):
21 # Guess page format if omitted, but default to Markdown for friendlier excepti ons 22 # Guess page format if omitted, but default to Markdown for friendlier excepti ons
22 if format is None: 23 if format is None:
23 for format in converters.iterkeys(): 24 for format in converters.iterkeys():
24 if source.has_page(page, format): 25 if source.has_page(page, format):
25 break 26 break
26 else: 27 else:
27 format = "md" 28 format = "md"
28 29
29 params = { 30 params = {
30 "source": source, 31 "source": source,
31 "template": "default", 32 "template": "default",
32 "locale": locale, 33 "locale": locale,
33 "localecomments": {},
Wladimir Palant 2015/06/29 19:05:38 This should no longer be necessary if locale data
kzar 2015/07/02 12:33:13 Done.
34 "page": page, 34 "page": page,
35 "pagedata": source.read_page(page, format), 35 "pagedata": source.read_page(page, format),
36 "config": source.read_config(), 36 "config": source.read_config(),
37 "localized_string_callback": localized_string_callback,
37 } 38 }
38 39
39 localefile = page 40 localefile = page
40 if params["config"].has_option("locale_overrides", page): 41 if params["config"].has_option("locale_overrides", page):
41 localefile = params["config"].get("locale_overrides", page) 42 localefile = params["config"].get("locale_overrides", page)
42 params["localedata"] = source.read_locale(params["locale"], localefile) 43 params["localedata"] = source.read_locale(params["locale"], localefile)
43 44
44 if params["config"].has_option("general", "siteurl"): 45 if params["config"].has_option("general", "siteurl"):
45 if site_url_override: 46 if site_url_override:
46 params["site_url"] = site_url_override 47 params["site_url"] = site_url_override
(...skipping 24 matching lines...) Expand all
71 72
72 params["head"], params["body"] = converter() 73 params["head"], params["body"] = converter()
73 if converter.total_translations > 0: 74 if converter.total_translations > 0:
74 params["translation_ratio"] = (1 - 75 params["translation_ratio"] = (1 -
75 float(converter.missing_translations) / converter.total_translations) 76 float(converter.missing_translations) / converter.total_translations)
76 else: 77 else:
77 params["translation_ratio"] = 1 78 params["translation_ratio"] = 1
78 79
79 return params 80 return params
80 81
81 def process_page(source, locale, page, format=None, site_url_override=None): 82 def process_page(source, locale, page, format=None, site_url_override=None,
83 localized_string_callback=None):
82 return TemplateConverter( 84 return TemplateConverter(
83 get_page_params(source, locale, page, format, site_url_override), 85 get_page_params(source, locale, page, format,
86 site_url_override, localized_string_callback),
84 key="templatedata" 87 key="templatedata"
85 )() 88 )()
LEFTRIGHT

Powered by Google App Engine
This is Rietveld