I have a model:
class Server(models.Model):
serverId = models.IntegerField(verbose_name=_("serverId"))
name = models.CharField(max_length=200, verbose_name=_("server_name"))
ip = models.CharField(max_length=200, verbose_name=_("ip"))
cport = models.IntegerField(default=5000, verbose_name=_("cport"))
aport = models.IntegerField(default=1000, verbose_name=_("aport"))
hport = models.IntegerField(default=2000, verbose_name=_("hport"))
version = models.CharField(max_length=100, verbose_name=_("version"))
serverGroup = models.ForeignKey(Group, null=True, blank=True,
verbose_name=_('server_group'))
class Meta:
db_table = u'server'
def __unicode__(self):
return self.name
and the modelform:
class ServerForm(ModelForm):
class Meta:
model = Server
from within this app directory I did
$ mkdir locale
$ django-admin.py makemessages -l zh_CN
then I provided the translation in locale/zh_CN/LC_MESSAGES/django.po
then I did
$ django-admin.py compilemessages
then I ran the development server:
$ python manage.py runserver
and went to look at the url http://127.0.0.1:8000 in firefox and the translation displayed. So I thought I did right and I deployed the project on the same machine using nginx + fastcgi with nothing changed in the whole project. Then I go to the url http://127.0.0.1, and then the the modelform shows English there. It didn’t localize to Chinese.
I’ve googled much and read many docs from docs.djangoproject.com and still don’t know how to solve the problem. So I ask here.
I only set LANGUAGE_CODE = ‘zh_CN’ in my settings.py and leave everything on deafult. My django version is 1.2.4
Any of your comments are appreciated.
Make sure you are using lazy_translation. Are you importing
ugettext_lazyorugettext?http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/#lazy-translation