How to translate the application name in Django CMS Admin?

本秂侑毒 提交于 2019-12-11 02:44:29

问题


How can I translate the application name in the Django CMS admin?

See the screenshot:


回答1:


The answer below was correct for Django 1.4 or 1.5, I believe. For more modern answer, see https://stackoverflow.com/a/32431808/1067717


Have a look at this previously asked question on the similar topic for internationalization in Django.

Internally, it uses Model._meta.app_label to display the application name. Inspect admin view and its template for further information.




回答2:


OK. I have found how to translate the app name without changing the database name. Example (inside apps.py of app you want to translate):

from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _

class MyAppConfig(AppConfig):
    name = 'MyApp'
    verbose_name = _('Transalation of MyApp here')

Run makemessages -a and after altering django.po run compilemessages and you are done. Hit refresh in admin and your app name is translated.




回答3:


It might too late to answer this question but i am sharing my experience.

Add below mention code to model.py

VERBOSE_NAME = _('Appname')

After the use this

django-admin.py makemessages -a
django-admin.py compilemessages

This will add entry to django.po.




回答4:


I don't know which CMS you used,so I just give you a sample code below. Maybe you can change the fields in your models.py file like this:

class Entry(models.Model):
    title         = models.CharField(u'标题',max_length=300)

    # other fields here

The code above is work well in my project(django 1.4.2),the first param(string) in CharField() will display in my Admin view,I think it is useful for you.

The full code in my project:https://github.com/tianyu0915/pythoner.net/blob/master/pythoner/wiki/models.py#L69



来源:https://stackoverflow.com/questions/19168671/how-to-translate-the-application-name-in-django-cms-admin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!