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

Delta Between Two Patch Sets: cms/sources.py

Issue 29317015: Issue 2625 - [cms] Crowdin synchronisation script (Closed)
Left Patch Set: Addressed further feedback Created July 11, 2015, 7:17 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/converters.py ('k') | cms/utils.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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 def has_locale(self, locale, page): 162 def has_locale(self, locale, page):
163 config = self.read_config() 163 config = self.read_config()
164 try: 164 try:
165 page = config.get("locale_overrides", page) 165 page = config.get("locale_overrides", page)
166 except ConfigParser.Error: 166 except ConfigParser.Error:
167 pass 167 pass
168 return self.has_file(self.locale_filename(locale, page)) 168 return self.has_file(self.locale_filename(locale, page))
169 169
170 def read_locale(self, locale, page): 170 def read_locale(self, locale, page):
171 default_locale = self.read_config().get("general", "defaultlocale") 171 default_locale = self.read_config().get("general", "defaultlocale")
172 if locale == default_locale: 172 result = collections.OrderedDict()
173 result = collections.OrderedDict() 173 if locale != default_locale:
174 else: 174 result.update(self.read_locale(default_locale, page))
175 result = collections.OrderedDict(self.read_locale(default_locale, page))
176 175
177 if self.has_locale(locale, page): 176 if self.has_locale(locale, page):
178 filedata = self.read_file(self.locale_filename(locale, page)) 177 filedata = self.read_file(self.locale_filename(locale, page))
179 localedata = json.loads(filedata) 178 localedata = json.loads(filedata)
180 for key, value in localedata.iteritems(): 179 for key, value in localedata.iteritems():
181 result[key] = value["message"] 180 result[key] = value["message"]
182 181
183 return result 182 return result
184 183
185 # 184 #
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 path = os.path.join(dir, filename) 287 path = os.path.join(dir, filename)
289 if os.path.isfile(path): 288 if os.path.isfile(path):
290 result.append(relpath + filename) 289 result.append(relpath + filename)
291 elif os.path.isdir(path): 290 elif os.path.isdir(path):
292 do_list(path, relpath + filename + "/") 291 do_list(path, relpath + filename + "/")
293 do_list(self.get_path(subdir), "") 292 do_list(self.get_path(subdir), "")
294 return result 293 return result
295 294
296 def get_cache_dir(self): 295 def get_cache_dir(self):
297 return os.path.join(self._dir, "cache") 296 return os.path.join(self._dir, "cache")
LEFTRIGHT

Powered by Google App Engine
This is Rietveld