mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
i18n: updated translation doc to reflect the django_language and LANGUAGE_CODE format change
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@915 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2070258460
commit
a26e6a4d75
@ -85,7 +85,23 @@ This way only a lazy reference is stored for the string, not the actual translat
|
||||
The translation itself will be done when the string is used in a string context, like
|
||||
template rendering in the admin.
|
||||
|
||||
There is a standard problem with translations, that is pluralization of
|
||||
If you don't like the verbose name gettext_lazy, you can just alias it as _ - in the model
|
||||
file you will allways use lazy translations anyway. And it's a good idea to add translations
|
||||
for the field names and table names, too. This means writing explicit verbose_name and
|
||||
verbose_names options in the META subclass, though::
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
class Mything(meta.Model):
|
||||
|
||||
name = meta.CharField(_('Name'), help_text=_('This is the help text'))
|
||||
|
||||
class META:
|
||||
|
||||
verbose_name = _('Mything')
|
||||
verbose_name_plural = _('Mythings')
|
||||
|
||||
There is another standard problem with translations, that is pluralization of
|
||||
strings. This is done by the standard helper ngettext like so::
|
||||
|
||||
def hello_world(request, count):
|
||||
@ -199,9 +215,9 @@ setting, the middleware will look at the cookies for a django_language cookie.
|
||||
If that is found, it gives the language code.
|
||||
|
||||
The format for the explicit django_language parameters is allways the
|
||||
locale to use - for example it's pt_BR for Brazilian. If a base language
|
||||
language to use - for example it's pt-br for Brazilian. If a base language
|
||||
is available, but the sublanguage specified is not, the base language is used.
|
||||
For example if you specify de_AT (Austrian German), but there is only a
|
||||
For example if you specify de-at (Austrian German), but there is only a
|
||||
language de available, that language is used.
|
||||
|
||||
If neither the session nor the cookie carry a language code, the middleware
|
||||
|
Loading…
x
Reference in New Issue
Block a user