How can I translate the application name in the Django CMS admin?
See the screenshot:
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.
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).
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With