ankitpopli1891 / django-autotranslate

A simple Django app to automatically translate the pot (.po) files generated by django's makemessages command using google translate.
https://ankitpopli1891.github.io/django-autotranslate/
MIT License
70 stars 39 forks source link

%(placeholder)s incorrect when translating to Chinese Characters #16

Closed JustinWingChungHui closed 4 years ago

JustinWingChungHui commented 7 years ago

When converting something like Hello %(placeholder)s

To Chinese becomes: 您好%(占位符)

The % symbol becomes a different Unicode character . The ( character also becomes a different Unicode character . Also sometimes the s disappears or moves.

And so this unfortunately fails at the compilemessages stage

ankitpopli1891 commented 7 years ago

HI @JustinWingChungHui,

From the description it appears that the bug is related to compilemessages & we can't do much about it.

Although, I would be interested in finding the root cause. It may take some time due to my other commitments.

JustinWingChungHui commented 7 years ago

It happens when it gets put through Google translate. % becomes and ( becomes which are different Unicode characters.

You can see what happens if you input %(placeholder)s on the online Google translate site.

So either compilemessages needs to also recognise these two other characters to denote a placeholder or django-autotranslate needs to do something clever (not sure what!) with the placeholder for Asian languages.

ankitpopli1891 commented 7 years ago

Ah! I remember @generalov did some exceptional work & handled it here.

Ran the tests with these strings:

#: test_project/settings.py:16
#, python-format
msgid "Hello %(placeholder)s"
msgstr "你好 %(placeholder)s"

#: test_project/urls.py:27
#, python-format
msgid "Hello %(World)s"
msgstr "你好,世界__"         <---------- 'World' got translated :/

There is definite need for improvement here. :+1: I'll try to work on the issue this weekend.

Meanwhile, a PR is always welcomed :smile:

github-actions[bot] commented 4 years ago

Stale issue message