为什么在模板中翻译了一个短语,而没有翻译第二个短语?

时间:2019-07-03 14:27:55

标签: django django-templates

我不明白,为什么在模板中翻译了一个短语,而第二个短语却没有翻译?

可能是什么问题?

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 "залог - имеющееся недвижимость"

comission_type

#: 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在模型内部?..

0 个答案:

没有答案