OLD | NEW |
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 config = self.read_config() | 145 config = self.read_config() |
146 if config.has_option("locale_overrides", page): | 146 if config.has_option("locale_overrides", page): |
147 page = config.get("locale_overrides", page) | 147 page = config.get("locale_overrides", page) |
148 return self.has_file(self.locale_filename(locale, page)) | 148 return self.has_file(self.locale_filename(locale, page)) |
149 | 149 |
150 def read_locale(self, locale, page): | 150 def read_locale(self, locale, page): |
151 default_locale = self.read_config().get("general", "defaultlocale") | 151 default_locale = self.read_config().get("general", "defaultlocale") |
152 if locale == default_locale: | 152 if locale == default_locale: |
153 result = {} | 153 result = {} |
154 else: | 154 else: |
155 result = self.read_locale(default_locale, page) | 155 result = dict(self.read_locale(default_locale, page)) |
156 | 156 |
157 if self.has_locale(locale, page): | 157 if self.has_locale(locale, page): |
158 filedata = self.read_file(self.locale_filename(locale, page)) | 158 filedata = self.read_file(self.locale_filename(locale, page)) |
159 localedata = json.loads(filedata) | 159 localedata = json.loads(filedata) |
160 for key, value in localedata.iteritems(): | 160 for key, value in localedata.iteritems(): |
161 result[key] = value["message"] | 161 result[key] = value["message"] |
162 | 162 |
163 return result | 163 return result |
164 | 164 |
165 # | 165 # |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 return | 259 return |
260 | 260 |
261 for filename in files: | 261 for filename in files: |
262 path = os.path.join(dir, filename) | 262 path = os.path.join(dir, filename) |
263 if os.path.isfile(path): | 263 if os.path.isfile(path): |
264 result.append(relpath + filename) | 264 result.append(relpath + filename) |
265 elif os.path.isdir(path): | 265 elif os.path.isdir(path): |
266 do_list(path, relpath + filename + "/") | 266 do_list(path, relpath + filename + "/") |
267 do_list(self.get_path(subdir), "") | 267 do_list(self.get_path(subdir), "") |
268 return result | 268 return result |
OLD | NEW |