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

Delta Between Two Patch Sets: cms/converters.py

Issue 5242593268989952: Issue 2340 - Don`t generate pages if less than 30% have been translated (Closed)
Left Patch Set: Don`t link to pages that don`t exist Created May 6, 2015, 3:19 p.m.
Right Patch Set: Addressed comments Created May 6, 2015, 5:20 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/bin/generate_static_pages.py ('k') | cms/sources.py » ('j') | 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if locale == self._params["defaultlocale"]: 142 if locale == self._params["defaultlocale"]:
143 result = default 143 result = default
144 elif name in localedata: 144 elif name in localedata:
145 result = localedata[name].strip() 145 result = localedata[name].strip()
146 else: 146 else:
147 result = default 147 result = default
148 self.missing_translations += 1 148 self.missing_translations += 1
149 self.total_translations += 1 149 self.total_translations += 1
150 150
151 # Insert fixed strings 151 # Insert fixed strings
152 for i in range(len(fixed_strings)): 152 for i, fixed_string in enumerate(fixed_strings, 1):
153 result = re.sub(r"\{%d\}" % (i + 1), fixed_strings[i], result, 1) 153 result = result.replace("{%d}" % i, fixed_string)
154 154
155 # Insert attributes 155 # Insert attributes
156 result = escape(result) 156 result = escape(result)
157 def stringify_attribute((name, value)): 157 def stringify_attribute((name, value)):
158 return '%s="%s"' % ( 158 return '%s="%s"' % (
159 escape(name), 159 escape(name),
160 escape(self.insert_localized_strings(value, {})) 160 escape(self.insert_localized_strings(value, {}))
161 ) 161 )
162 162
163 for tag in self.whitelist: 163 for tag in self.whitelist:
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 stack.pop() 407 stack.pop()
408 stack[-1]["subitems"].append(item) 408 stack[-1]["subitems"].append(item)
409 stack.append(item) 409 stack.append(item)
410 return structured 410 return structured
411 411
412 converters = { 412 converters = {
413 "html": RawConverter, 413 "html": RawConverter,
414 "md": MarkdownConverter, 414 "md": MarkdownConverter,
415 "tmpl": TemplateConverter, 415 "tmpl": TemplateConverter,
416 } 416 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld