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

Delta Between Two Patch Sets: cms/converters.py

Issue 29317015: Issue 2625 - [cms] Crowdin synchronisation script (Closed)
Left Patch Set: Addressed Wladimir's feedback Created July 2, 2015, 12:29 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/bin/translate.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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 def re_escape(s): 133 def re_escape(s):
134 return re.escape(escape(s)) 134 return re.escape(escape(s))
135 135
136 # Extract tag attributes from default string 136 # Extract tag attributes from default string
137 default, saved_attributes, fixed_strings = self._attribute_parser.parse(defa ult, self._params["page"]) 137 default, saved_attributes, fixed_strings = self._attribute_parser.parse(defa ult, self._params["page"])
138 138
139 # Get translation 139 # Get translation
140 locale = self._params["locale"] 140 locale = self._params["locale"]
141 if locale == self._params["defaultlocale"]: 141 if locale == self._params["defaultlocale"]:
142 result = default 142 result = default
143 # Store the default string if required, e.g. for the translations script
144 if self._params["record_default_strings"]:
Sebastian Noack 2015/07/08 13:03:20 Is there any particular reason we call that functi
Wladimir Palant 2015/07/08 23:11:08 That's assumptions, the kind that might not be tru
Sebastian Noack 2015/07/09 21:26:55 Or the other way around. As far as I see it this c
Wladimir Palant 2015/07/10 21:24:04 True. If we generalize the parameter name into som
kzar 2015/07/11 19:21:17 Done.
145 self._params["record_default_strings"](page, name, default,
146 comment, fixed_strings)
147 elif name in localedata: 143 elif name in localedata:
148 result = localedata[name].strip() 144 result = localedata[name].strip()
149 else: 145 else:
150 result = default 146 result = default
151 self.missing_translations += 1 147 self.missing_translations += 1
152 self.total_translations += 1 148 self.total_translations += 1
149
150 # Perform callback with the string if required, e.g. for the translations sc ript
151 callback = self._params["localized_string_callback"]
152 if callback:
153 callback(page, locale, name, result, comment, fixed_strings)
154
153 155
154 # Insert fixed strings 156 # Insert fixed strings
155 for i, fixed_string in enumerate(fixed_strings, 1): 157 for i, fixed_string in enumerate(fixed_strings, 1):
156 result = result.replace("{%d}" % i, fixed_string) 158 result = result.replace("{%d}" % i, fixed_string)
157 159
158 # Insert attributes 160 # Insert attributes
159 result = escape(result) 161 result = escape(result)
160 def stringify_attribute((name, value)): 162 def stringify_attribute((name, value)):
161 return '%s="%s"' % ( 163 return '%s="%s"' % (
162 escape(name), 164 escape(name),
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 stack.pop() 405 stack.pop()
404 stack[-1]["subitems"].append(item) 406 stack[-1]["subitems"].append(item)
405 stack.append(item) 407 stack.append(item)
406 return structured 408 return structured
407 409
408 converters = { 410 converters = {
409 "html": RawConverter, 411 "html": RawConverter,
410 "md": MarkdownConverter, 412 "md": MarkdownConverter,
411 "tmpl": TemplateConverter, 413 "tmpl": TemplateConverter,
412 } 414 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld