我不明白,为什么在模板中翻译了一个短语,而第二个短语却没有翻译?
可能是什么问题?
python manage.py makemessages
python manage.py compilemessages
设置
LANGUAGE_CODE = 'ru'
USE_I18N = True
LANGUAGES = (
('ru', gettext('Russian')),
('kk', gettext('Kazakh')),
)
MODELTRANSLATION_DEFAULT_LANGUAGE = 'ru'
TEMPLATES = [
{
'OPTIONS': {
'context_processors': [
'django.template.context_processors.i18n',
'solid_i18n.middleware.SolidLocaleMiddleware',
SOLID_I18N_USE_REDIRECTS = True
模板
{% load l10n i18n %}
<div>{% trans credit.creditpayment_set.first.security %}</div> #It's translated
<div>{% trans credit.creditpayment_set.first.comission_type %}</div> #It's not translated
django.po(ru)
#: credits/models.py:70
msgid "Pledge - real estate"
msgstr "залог - имеющееся недвижимость"
#: credits/models.py:156
msgid "For consideration"
msgstr "Комиссия за рассмотрения"
models.py
SECURITY_WITHOUT = 'Without collateral and guarantee'
SECURITY_REAL = 'Pledge - real estate'
SECURITY_CHOICES = (
(SECURITY_WITHOUT, _('Without collateral and guarantee')),
(SECURITY_REAL, _('Pledge - real estate')),
)
class CreditPayment(models.Model):
COMISSION_TYPE_CONSIDERATION = 'for consideration'
COMISSION_TYPE_ORGANIZATION = 'for organization'
COMISSION_TYPE_CHOICES = (
(COMISSION_TYPE_CONSIDERATION, _('For consideration')),
(COMISSION_TYPE_ORGANIZATION, _('For organization')),
)
credit = models.ForeignKey(Credit, on_delete=models.CASCADE)
security = models.CharField(_('security'), max_length=255, choices=SECURITY_CHOICES, default=SECURITY_WITHOUT)
comission_type = models.CharField(_('comission type'), max_length=255, choices=COMISSION_CHOICES, default=COMISSION_MONTHLY, blank=True, null=True)
因为COMISSION_TYPE_CHOICES
在模型内部?..