如何翻译应用模板 [英] how to translate an app template

查看:151
本文介绍了如何翻译应用模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中使用多种语言,因此我已经遵循了这个 doc

I want to use multiple language in my app and for that i have followed this doc

在locale文件夹中创建django.po之后,我打开了,因为这个文件包含'#'告诉你你可以翻译哪一行。
但是这个文件只包含管理部分,它没有我的应用程序模板,即我的应用程序的HTML文件。

After the creation of django.po inside locale folder, I opened that, as this files contain '#' which told you that which line you can translate. But this file only contain admin part it does not have my app templates i.e., HTML files of my app.

那么如何翻译这些HTML文件,或者我应该怎么做,以便django.po文件也可以包含我的应用程序模板。

So how I can translate those HTML files, OR what should I have to do so that django.po file can also contain my app templates.

我只跟着这个

I have followed only this doc.

推荐答案

您需要使用 {%trans%} {%blocktrans%} 您的html文件之前的模板标签

You need to use the {% trans %} or {% blocktrans %} template tags in your html files before you run

python manage.py makemessages -l <locale>

如果你这样做,你的HTML模板在你的源代码树中,那么makemessages应该选择它们向上。如果您没有使用这些模板标签,那么您的.po文件中您将看不到任何输出。

If you have done that, and your HTML templates are inside your source tree, then makemessages should pick them up. If you haven't used those template tags, then you won't see any output from them in your .po file.

这篇关于如何翻译应用模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆