Django 和本地化无法识别包含带重音符号的字符串

发布于 2024-10-08 20:05:22 字数 210 浏览 0 评论 0原文

我正在尝试使用 Django 将一些字符串从意大利语本地化为其他语言。一切工作正常,但不适用于包含重音字符的字符串。

原始文件以及翻译后的 .po 文件均以 UTF-8 格式保存。字符串是相同的,compilemessages 命令运行时不会出现任何警告。但是,当我尝试打开该页面时,我没有得到这些字符串的翻译版本,而只有这些字符串。

我应该检查什么?

I'm trying to use Django to localize some strings from Italian to other languages. Everything is working fine but not with strings which contain accented chars.

The original file is saved in UTF-8 as well as the translated .po file. The strings are identical and the compilemessages command works without any warning. When I try and open the page though, I don't get the translated version for those strings and only those.

What should I check?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不甘平庸 2024-10-15 20:05:22

这对于 Django 0.76 有效:

{% trans "This is the title." %}

引号中的所有内容都必须采用标准 ASCII。重音字符将不会被识别。基本上,您需要在那里放置一个标签,然后也为您的默认语言生成一个 .po 文件。

This is valid for Django 0.76:

{% trans "This is the title." %}

Everything in the quotes needs to be in standard ASCII. Accented characters won't be recognised. Basically you need to put a label there, and then generate a .po file also for your default language.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文