Hi Django users,
-- We have our site.name and other site names (we have 4 sites in Django right now) in templates such as base.html. The site is taken from model Site (```from django.contrib.sites.models import Site```). In templates we just use "{{ site.name }}" or "{{ other_site.name }}". How do we translate these site names to other languages? What is the correct way? Currently I only need the site names in English and Hebrew, but maybe later I will want other languages too.
Our settings file translates the site title. Is it better to translate it in the templates? Because we don't want to translate it twice. If the site title is not defined, the default is the site name (which we want for 2 of our sites). But we need it translated.
from django.conf import settings as dj_settings
from django.contrib.sites.models import Site
def sites(request):
site = Site.objects.get_current()
site_title = site.name
if hasattr(dj_settings, 'SITE_TITLE'):
site_title = dj_settings.SITE_TITLE
return {
'site': site,
'site_title': site_title,
'sites': Site.objects.all().order_by('pk'),
}
You can see the code on GitHub: https://github.com/urievenchen/speedy-net
Thanks,
Uri.
| Uri Even-Chen |
| Phone: +972-54-3995700 Email: uri@speedy.net Website: http://www.speedysoftware.com/uri/en/ |
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMQ2MsHRPzzdGVcQi1D0g%2BPe6GS0gjhbZaEOrUvH0-PMGq%3DdRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment