2

Is there any way one could automatically mark all model names and attributes for translation, without specifying verbose_name/_plural on each one of them?

Doesn't feel very DRY to do this every time:

class Profile(models.Model):
    length = models.IntegerField(_('length'))
    weight = models.IntegerField(_('weight'))
    favorite_movies = models.CharField(_('favorite movies'), max_length=100)
    favorite_quote = models.CharField(_('favorite quote'), max_length=30)
    religious_views = models.CharField(_('religious views'), max_length=30)
    political_views = models.CharField(_('political views'), max_length=30)

    class Meta:
        verbose_name = _('profile')
        verbose_name_plural = _('profiles')
jmagnusson
  • 5,799
  • 4
  • 43
  • 38
  • 1
    By taking DRY too strictly one could say that even writing views, models or programs for that matter over and over is DRY violation. `_` is used so that you write less and save space. DRY simply implies you don't repeat a part of your program logic if you don't really need to, so it is easier to maintain and work with not that you shouldn't use function more then once. That being said, you could perhaps mark all of your strings for translation using some dark magic, but when few strings popup that you do not wan't to translate you would be repeating "don't translate" method. – Davor Lucic Jun 17 '10 at 11:36
  • Hm I guess so. This functionality would make more sense to have in makemessages, like an optional argument. – jmagnusson Jun 17 '10 at 12:12

0 Answers0