LEFT | RIGHT |
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 Loading... |
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 Loading... |
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 } |
LEFT | RIGHT |