Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django don';不要在模板中翻译几个单词_Django_Internationalization_Translation - Fatal编程技术网

Django don';不要在模板中翻译几个单词

Django don';不要在模板中翻译几个单词,django,internationalization,translation,Django,Internationalization,Translation,我有这个模板: {% if apartment.property.type == 'condo' %}{% trans 'Apartments' %}{% endif %} {% trans 'Square' %} django.po: #: templates/main/tags/special.html:11 templates/main/tags/special.html:28 #, fuzzy msgid "Apartments" msgstr "Квартира" #: templ

我有这个模板:

{% if apartment.property.type == 'condo' %}{% trans 'Apartments' %}{% endif %}
{% trans 'Square' %}
django.po:

#: templates/main/tags/special.html:11 templates/main/tags/special.html:28
#, fuzzy
msgid "Apartments"
msgstr "Квартира"

#: templates/main/tags/special.html:44
msgid "Square"
msgstr "Площадь"
我先执行“生成消息”,然后执行“编译消息”命令。然后我重启服务器。 但是:当我在浏览器中打开站点时,我看到:

 Apartments
 Площадь

因此,1个单词被翻译,1个单词未被翻译。更多信息:“公寓”一词不会在所有网站的任何地方翻译。我做错了什么?

字符串被标记为fuzzy,因此Gettext不包括在编译的翻译中(由
编译消息生成)。一旦原始字符串发生了一些变化,字符串通常会被标记为fuzzy,但也可能有其他原因。

好的,但为什么这个字符串不被翻译?我刚才尝试将单词“families”从“if”中移出,然后生成消息(没有fuzzy)、编译消息。但结果是一样的:“公寓”不会在网站上翻译。我从.po文件中删除了“#,fuzzy”,这对我很有帮助。但我不明白为什么django会在po文件中创建模糊字符串?为什么我要删除它?你能解释一下吗?