danhper / python-i18n

Easy to use i18n library for Python
https://pypi.python.org/pypi/python-i18n
MIT License
228 stars 45 forks source link

Strings are getting escaped #6

Closed retr0h closed 6 years ago

retr0h commented 6 years ago

It appears strings are getting escaped. My unit tests are failing while switching out to strings generated by i18n.t(). Is there a way to prevent this? I'd like the terminal to handle the newline vs getting an escaped newline.

---
en:
  command:
    failed: |
      Idempotence test failed because of the following tasks:\n%{failed_tasks}
E         - ('Idempotence test failed because of the following tasks:\\n',)
E         ?                                                           -
E         + ('Idempotence test failed because of the following tasks:\n',)
danhper commented 6 years ago

Hi,

I think this is rather related to how yaml handles escaped characters. You could change your yml file either to

---
en:
  command:
    failed: |
      Idempotence test failed because of the following tasks:
      %{failed_tasks}

or to

---
en:
  command:
    failed: "Idempotence test failed because of the following tasks:\n%{failed_tasks}"
retr0h commented 6 years ago

@tuvistavie oh duh, thanks that solved it.