Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to translate the application name in Django CMS Admin?

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

See the screenshot:

Screenshot

like image 258
Nikolay Georgiev Avatar asked Oct 03 '13 20:10

Nikolay Georgiev


People also ask

How do I change app label in Django admin?

in django 3.0+ you just need to change the folder name and inside the apps.py change the "name" inside the "(appname)Config" class to the new name.

Can we change app name in Django?

Delete the database tables of the app to be renamed. Rename the folder of the app. Change any references to your app in their dependencies, i.e. the app's views.py , urls.py , 'manage.py' , and settings.py files. If your models.py 's Meta Class has app_name listed, make sure to rename that too (mentioned by @will).

What is Gettext_lazy in Django?

gettext_lazy() In definitions like forms or models you should use gettext_lazy because the code of this definitions is only executed once (mostly on django's startup); gettext_lazy translates the strings in a lazy fashion, which means, eg.


2 Answers

UPDATE: For Django 3+ import gettext_lazy instead of ugettext_lazy. Like this:

from django.utils.translation import gettext_lazy as _

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.

like image 132
nik_m Avatar answered Sep 22 '22 11:09

nik_m


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.

like image 32
Vishnu Avatar answered Sep 19 '22 11:09

Vishnu