Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
can't update .po file in Django 1.8.8

I'm new to Django and now I am practicing Django Internationalization, intending to show my webpages in Chinese, however:

Whatever changes I've made into the django.po file, and used compilemesseages to generate the .mo file, the pages still returned the previous translations, even if I deleted the .po file to generate a new one. Did I miss something? If so, please tell me, thank you :)

This is my settings:

LANGUAGE_CODE = 'zh-CN'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

LANGUAGES = (
    ('en', ('English')),
    ('zh_CN', ('中文简体')),
    ('zh-hant', ('中文繁體')),
)
LOCALE_PATHS = (
    os.path.join(BASE_DIR, 'locale'),
)

also I've added the 'django.middleware.locale.LocaleMiddleware'into settings.py, just like this:

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

what I was test is this function in views.py:

def test1_view(request): 
    n = 2
    weekdays = [_('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday'), 
_('Sunday')] 
    return HttpResponse(weekdays[n])

the django.po file generated at /locale/zh_CN/LC_MESSAGES/django.po, and i'm sure i had delete the #,fuzzy:

#: testdeploy/views.py:64
msgid "Monday"
msgstr "一"

#: testdeploy/views.py:64
msgid "Tuesday"
msgstr "二"

#: testdeploy/views.py:64
msgid "Wednesday"
msgstr "三"

#: testdeploy/views.py:64
msgid "Thursday"
msgstr "四"

#: testdeploy/views.py:64
msgid "Friday"
msgstr "五"

#: testdeploy/views.py:64
msgid "Saturday"
msgstr "六"

#: testdeploy/views.py:65
msgid "Sunday"
msgstr "七"

then I used the $ python manage.py compilemessages and the .mo file generated, but when I restarted the server, the page was still as the same as the first time I modified the .po file: it just showed "星期三" instead of "三".

I'm really confused about this, are there some cookies that I should empty to ensure the changes could work? TOT

PS: My django version is 1.8.8

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

After almost 3 days , I finally solved this problem by writing emails for help. Actually this problem seemed to be caused by some specific languages settings, such as Chinese: I changed my settings.py:

LANGUAGES = (
    ('en', ('English')),
    ('zh-CN', ('中文简体')),
    ('zh-TW', ('中文繁體')),
)

which used '-' instead of '_', however still used

$ python manage.py makemessages -l zh_CN 

to generate the django.po(where the '_' was still the same).

@Emin Mastizada, thank you all the same :)

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda