| Index: cms/converters.py |
| diff --git a/cms/converters.py b/cms/converters.py |
| index 8f602f3f36149a3b70ac17f6054197a84756b056..b90fadacd89ed532d8727bf4757a1abbcccfe914 100644 |
| --- a/cms/converters.py |
| +++ b/cms/converters.py |
| @@ -125,7 +125,7 @@ class Converter: |
| params[name.strip()] = value.strip() |
| params[key] = "".join(lines) |
| - def localize_string(self, name, default, localedata, escapes): |
| + def localize_string(self, name, default, comment, localedata, escapes): |
|
kzar
2015/06/15 14:24:28
We previously threw away string comments, now we n
|
| def escape(s): |
| return re.sub(r".", |
| lambda match: escapes.get(match.group(0), match.group(0)), |
| @@ -147,6 +147,17 @@ class Converter: |
| self.missing_translations += 1 |
| self.total_translations += 1 |
| + # Keep a record of the default translations |
| + if locale == self._params["defaultlocale"]: |
|
Wladimir Palant
2015/06/29 19:05:38
This case is already checked above (getting transl
kzar
2015/07/02 12:33:12
Done.
|
| + localedata[name] = result |
| + # Append a note about fixed strings to the string comment for translators |
|
kzar
2015/06/15 14:24:28
Without this translators would have way to know wh
|
| + if fixed_strings: |
| + comment = comment + " " if comment else "" |
| + self._params["localecomments"][name] = comment + ( |
| + "[" + ", ".join(["%d: %s" % (i, s) for i, s in |
|
Wladimir Palant
2015/06/29 19:05:38
", ".join("{%d}: %s" (i, s) for i, s in ...)
In o
kzar
2015/07/02 12:33:13
Done.
|
| + enumerate(fixed_strings, 1)]) + "]" |
| + ) |
|
Wladimir Palant
2015/06/29 19:05:37
And what about comments for strings without fixed
kzar
2015/07/02 12:33:13
Whoops, good point.
Done.
|
| + |
| # Insert fixed strings |
| for i, fixed_string in enumerate(fixed_strings, 1): |
| result = result.replace("{%d}" % i, fixed_string) |
| @@ -185,9 +196,8 @@ class Converter: |
| name, comment, default = match.groups() |
| default = to_html(default).strip() |
| - # Note: We currently ignore the comment, it is only relevant when |
| - # generating the master translation. |
| - return self.localize_string(name, default, self._params["localedata"], escapes) |
| + # Note: The comment, it is only relevant when uploading translations |
|
Wladimir Palant
2015/06/29 19:05:38
This is the wrong place for this comment, it is de
kzar
2015/07/02 12:33:13
Done.
|
| + return self.localize_string(name, default, comment, self._params["localedata"], escapes) |
| return re.sub( |
| r"{{\s*" |
| @@ -352,15 +362,14 @@ class TemplateConverter(Converter): |
| return result |
| def translate(self, default, name, comment=None): |
| - # Note: We currently ignore the comment, it is only relevant when |
| - # generating the master translation. |
| + # Note: The comment, it is only relevant when uploading translations |
|
Wladimir Palant
2015/06/29 19:05:38
Same here, this comment should be moved into funct
kzar
2015/07/02 12:33:13
Done.
|
| localedata = self._params["localedata"] |
| - return jinja2.Markup(self.localize_string(name, default, localedata, html_escapes)) |
| + return jinja2.Markup(self.localize_string(name, default, comment, localedata, html_escapes)) |
| def get_string(self, name, page): |
| - localedata = self._params["source"].read_locale(self._params["locale"], page) |
| - default = localedata[name] |
| - return jinja2.Markup(self.localize_string(name, default, localedata, html_escapes)) |
| + default = self._params["source"].read_locale(self._params["locale"], page)[name] |
|
kzar
2015/06/15 14:24:28
This change is required so that strings included w
Wladimir Palant
2015/06/29 19:05:38
This change also happens to be wrong. Each page in
kzar
2015/07/02 12:33:13
Done.
|
| + localedata = self._params["localedata"] |
| + return jinja2.Markup(self.localize_string(name, default, "", localedata, html_escapes)) |
| def get_page_content(self, page, locale=None): |
| from cms.utils import get_page_params |