i18n model field not translated

53 views
Skip to first unread message

otonk

unread,
Nov 5, 2007, 11:15:22 PM11/5/07
to Django users
Hi, I am working on a multilingual project, mainly in indonesia and
english.
i tried to do i18n on my model fields but i cant get it work on the
admin site.
the model name is translated, however the fields name is not.

here's my model.py

class Company(models.Model):
name = models.CharField(_('name'), help_text=_('This is the
help text'), max_length = 255)
logo = models.ImageField(_('logo'), upload_to = 'logo/%Y%m%d
%H%M%S')
detail = models.TextField(_('detail'), blank = True)
letterhead = models.ImageField(_('letterhead'), upload_to = 'logo/
%Y%m%d%H%M%S', blank = True)

class Admin:
pass
fields = (
(None,{
'fields': ('name','logo','detail')
}),
('Optional', {
'classes' : 'collapse',
'fields' : ('letterhead',)
}),
)

class Meta:
verbose_name = _('Company')
verbose_name_plural = _('Companies')

def __unicode__(self):
return '%s' % self.name

as you can see the field 'name', the help_text is translated, but the
'name' itself is not translated.
did i do something wrong?

cschand

unread,
Nov 5, 2007, 11:27:51 PM11/5/07
to Django users
Hi otonk

Use ugettex_lazy form models

from django.utils.translation import ugettext_lazy as _

cschand

otonk

unread,
Nov 5, 2007, 11:51:54 PM11/5/07
to Django users
I did..

from django.db import models


from django.utils.translation import ugettext_lazy as _

--- code emmited ---

name = models.CharField(_('name'), help_text=_('This is the
help text'), max_length = 255)

--- code emmited ---

on the above code, the
[ help_text=_('This is the help text') ]
is translated.. however the _('name') is not

cschand

unread,
Nov 6, 2007, 12:36:21 AM11/6/07
to Django users
Try this

name = models.CharField(verbose_name=_('name'),


help_text=_('This is the
help text'), max_length = 255)

otonk

unread,
Nov 6, 2007, 12:55:28 AM11/6/07
to Django users
its not working...

isnt verbose_name is for meta class?..

otonk

unread,
Nov 6, 2007, 3:01:09 AM11/6/07
to Django users
problem solved..

it lies on the django.po

i havent remove the

#, fuzzy

mark.. thats why its not translated

link: http://groups.google.com/group/django-users/browse_thread/thread/e8476fa11cefc2b7

Notice that the message in question is marked as "fuzzy". That means
the
translation does not quite match the source string. I cannot read
Chinese well enough to know if the string is at all close, but one
obvious difference is that the source string contains a "%d" format
marker whilst the translation contains a "%s" marker.

By default, fuzzy translations are not included in the output. A
translator has to check each one, verify it is correct (or correct it)
and remove the fuzzy comment. Then the result will be include in the
MO
file.

You may wish to update the file and submit a diff of the changes to
Trac
so that it can be committed.


Thanks for the group..

Reply all
Reply to author
Forward
0 new messages