Django

Code

Ticket #1668 (closed: duplicate)

Opened 4 years ago

Last modified 3 months ago

Translate module names via make-messages.py

Reported by: Rudolph Assigned to: hugo
Milestone: Component: Internationalization
Version: SVN Keywords: i18n translate module
Cc: akaihol+django@ambitone.com, bronger@physik.rwth-aachen.de Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

make-messages.diff (1.0 kB) - added by Evren Esat Özkan <sleytr@gmail.com> on 10/05/07 03:16:44.
make-messages.py patch to add app names to django.po file
django_admin_index.html.diff (0.6 kB) - added by Evren Esat Özkan <sleytr@gmail.com> on 10/05/07 03:18:11.
admin index.html patch to change blocktrans to trans for app.names

Change History

06/02/06 00:35:06 changed by adrian

  • status changed from new to closed.
  • resolution set to invalid.

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

06/06/06 10:28:53 changed by hugo

  • status changed from closed to reopened.
  • resolution deleted.

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?

07/13/06 16:30:43 changed by anonymous

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

11/03/06 07:20:26 changed by hugo

  • status changed from reopened to closed.
  • resolution set to wontfix.

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 ;)

12/10/06 03:15:29 changed by Rudolph

  • status changed from closed to reopened.
  • resolution deleted.

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.

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted

01/25/07 20:42:09 changed by Simon G. <dev@simon.net.nz>

  • keywords set to i18n translate module.
  • summary changed from Module name doesn't get translated in M-R to Translate module names via gettext_noop.
  • stage changed from Unreviewed to Design decision needed.

04/25/07 06:14:53 changed by mtredinnick

  • status changed from reopened to closed.
  • resolution set to wontfix.

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.

10/05/07 03:15:39 changed by Evren Esat Özkan <sleytr@gmail.com>

  • status changed from closed to reopened.
  • has_patch set to 1.
  • resolution deleted.

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.

10/05/07 03:16:44 changed by Evren Esat Özkan <sleytr@gmail.com>

  • attachment make-messages.diff added.

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

10/05/07 03:18:11 changed by Evren Esat Özkan <sleytr@gmail.com>

  • attachment django_admin_index.html.diff added.

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

10/05/07 05:58:54 changed by Evren Esat Özkan <sleytr@gmail.com>

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

10/17/07 03:04:51 changed by akaihola

  • cc set to akaihol+django@ambitone.com.

10/17/07 03:06:07 changed by akaihola

I think #3591 is related.

11/30/07 15:29:20 changed by jacob

  • stage changed from Design decision needed to Accepted.

11/04/09 14:43:34 changed by bronger

  • cc changed from akaihol+django@ambitone.com to akaihol+django@ambitone.com, bronger@physik.rwth-aachen.de.

04/22/10 16:23:45 changed by adamnelson

  • status changed from reopened to closed.
  • resolution set to duplicate.

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


Add/Change #1668 (Translate module names via make-messages.py)




Change Properties
Action