Opened 9 years ago

Closed 5 years ago

#1668 closed defect (duplicate)

Translate module names via make-messages.py

Reported by: Rudolph Owned by: hugo
Component: Internationalization Version: master
Severity: normal Keywords: i18n translate module
Cc: akaihol+django@…, bronger@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Translation of the module name on te frontpage of the admin
interface. I understood this should be done in the init.py file,
like this (put this in the docs!):

from django.utils.translation import gettext_noop
    gettext_noop('my module name')

When running make-messages.py, I can see the string appear in the PO
file. But the Admin interface still uses the untranslated string (at several places).

Attachments (2)

make-messages.diff (994 bytes) - added by Evren Esat Özkan <sleytr@…> 7 years ago.
make-messages.py patch to add app names to django.po file
django_admin_index.html.diff (601 bytes) - added by Evren Esat Özkan <sleytr@…> 7 years ago.
admin index.html patch to change blocktrans to trans for app.names

Download all attachments as: .zip

Change History (17)

comment:1 Changed 9 years ago by adrian

  • Resolution set to invalid
  • Status changed from new to closed

I'm not exactly sure what this means. Please reopen if it's still a problem.

comment:2 Changed 9 years ago by hugo

  • Resolution invalid deleted
  • Status changed from closed to reopened

The problem is, the admin doesn't try to translate module names - not even it's own module names it delivers with django. There was some discussion about this in the group:

http://groups.google.com/group/Django-I18N/browse_thread/thread/5f262db230bb393d

This could be incorporated in some way into the basic source - like adding gettext_noop() calls with the application names to some places, maybe __init__.py or some other code. It could even be some dummy line in the model definition - the gettext stuff doesn't care.

The idea is just to put a translation hook into some python file and to use the translation calls in the admin templates, so that application names can be translated as other stuff.

The only problem with this - and that's why I not just put in this solution - is that you would have to write the application name explicitely somewhere down. Currently it is taken from the module name, so this would be repetition for the sake of translation.

Comments?

comment:3 Changed 9 years ago by anonymous

  • milestone changed from Version 0.92 to Version 1.0
  • Version changed from magic-removal to SVN

comment:4 Changed 8 years ago by hugo

  • Resolution set to wontfix
  • Status changed from reopened to closed

Since nobody had any good suggestions and the solutions involved are rather hacky, I close this for now. Anybody with a good idea on how to solve this can open a new ticket. preferably with patch ;)

comment:5 Changed 8 years ago by Rudolph

  • Resolution wontfix deleted
  • Status changed from closed to reopened

How about doing it like this in a models.py file:

VERBOSE_NAME = _('polls')

class Poll(models.Model):
    question = CharField(_('question'), maxlength=50)
    etc. etc.

comment:6 Changed 8 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

comment:7 Changed 8 years ago by Simon G. <dev@…>

  • Keywords i18n translate module added
  • Summary changed from Module name doesn't get translated in M-R to Translate module names via gettext_noop
  • Triage Stage changed from Unreviewed to Design decision needed

comment:8 Changed 8 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from reopened to closed

I'm going to close this for the same reason it was originally closed: nobody has come up with a good solution. Any acceptable solution will not require rewriting the model name again and will ideally not require running import on the Python file to extract the string name (because that can have side-effects when extracting the strings, including security problems).

Please don't reopen this ticket without first bringing up suggestions on the django-developers list.

comment:9 Changed 7 years ago by Evren Esat Özkan <sleytr@…>

  • Has patch set
  • Resolution wontfix deleted
  • Status changed from closed to reopened

I've created a patch for make-messages.py to add app names to
django.po file. With this patch, make-messages.py creates a temporary html file with installed app
names first, then runs make_messages() and removes temporary file.

I also changed the admin/index.html template because it's not translate app.names with blocktrans tag.

Changed 7 years ago by Evren Esat Özkan <sleytr@…>

make-messages.py patch to add app names to django.po file

Changed 7 years ago by Evren Esat Özkan <sleytr@…>

admin index.html patch to change blocktrans to trans for app.names

comment:10 Changed 7 years ago by Evren Esat Özkan <sleytr@…>

  • Summary changed from Translate module names via gettext_noop to Translate module names via make-messages.py

comment:11 Changed 7 years ago by akaihola

  • Cc akaihol+django@… added

comment:12 Changed 7 years ago by akaihola

I think #3591 is related.

comment:13 Changed 7 years ago by jacob

  • Triage Stage changed from Design decision needed to Accepted

comment:14 Changed 5 years ago by bronger

  • Cc bronger@… added

comment:15 Changed 5 years ago by adamnelson

  • Resolution set to duplicate
  • Status changed from reopened to closed

#3591 is the more active ticket on this so this should be duplicate - even though it's older.

Note: See TracTickets for help on using tickets.
Back to Top