Opened 9 years ago

Last modified 12 months ago

#6376 assigned New feature

Please don't force the usage of the 'django' gettext domain

Reported by: dennis@… Owned by: LiquidPL
Component: Internationalization Version: master
Severity: Normal Keywords: gettext
Cc: clouserw@…, fwenzel, 4glitch@…, raymond.penners@…, LiquidPL Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


I'm using django as a library in my non-web-based application. As such I prefer not to use the 'django' gettext domain but my own. I currently work around it with some symlinking trickery since being compatible with upstream django is more important than not having workarounds, but it would be great if django supported this. To illustrate what I mean, I've attached a simple and untested patch against current svn (rev 7020).

Attachments (1)

gettext_domain.patch (1.7 KB) - added by dennis@… 9 years ago.
SImple and untested patch

Download all attachments as: .zip

Change History (20)

Changed 9 years ago by dennis@…

SImple and untested patch

comment:1 Changed 9 years ago by Bastian Kleineidam <calvin@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

If you change the domain you also have to rename, which I think is awkward.
You could use gettext.translation('django') for django-related strings and gettext.translation('yourapp') for other strings. This way your translations are separate and don't interfere with the django ones.

comment:2 Changed 9 years ago by anonymous

That doesn't work for my use case: template strings with {% trans %}/{% blocktrans %}. I'm using the django db/model api and templating system, nothing else. So no translated strings from django are being used, but the translation infrastructure is.

comment:3 Changed 9 years ago by Simon Greenhill <dev@…>

  • Has patch set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Design decision needed

comment:4 Changed 9 years ago by mtredinnick

I don't think the proposed solution is the right approach. It is best practice that the translation domain for a library or reusable component does not change, that way it is shared between all apps that want to use it. I'd prefer to see a way to specify additional translation domains, since that will allow different apps to ship in different domains.

That might be an extra template tag or something, I'm not sure. It's better than a setting, which isn't something application authors will know about -- it's in the control of the user/installer -- so they won't be able to create appropriate translation files. Application authors must be able to create PO files in their applications and users of those applications must be able to use them, so a setting can't work.

comment:5 Changed 8 years ago by mtredinnick

  • Triage Stage changed from Design decision needed to Someday/Maybe

comment:6 Changed 7 years ago by clouserw

  • Cc clouserw@… added

comment:7 Changed 5 years ago by julien

  • Severity set to Normal
  • Type set to New feature

comment:8 Changed 5 years ago by julien

  • Needs tests set

comment:9 Changed 5 years ago by fwenzel

  • Cc fwenzel added
  • Easy pickings unset

comment:10 Changed 5 years ago by fwenzel

  • Easy pickings set

sorry, didn't mean to unset "easy pickings".

comment:11 Changed 5 years ago by jezdez

  • Easy pickings unset

Yeah, you didn't unset it, it simply didn't have any value.

comment:12 Changed 5 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:13 Changed 3 years ago by ramiro

  • Triage Stage changed from Someday/Maybe to Accepted

#20070 asked for the same feature and was accepted by Jacob.

comment:14 Changed 3 years ago by 4glitch@…

  • Cc 4glitch@… added

comment:15 Changed 3 years ago by pennersr

  • Cc raymond.penners@… added

comment:16 Changed 13 months ago by LiquidPL

  • Cc LiquidPL added
  • Has patch unset
  • Owner changed from nobody to LiquidPL
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:17 Changed 13 months ago by LiquidPL

  • Has patch set
  • Needs tests unset

Created a pull request:

Added a setting LOCALE_FILENAMES, allowing to specify what filenames should be looked for by the internationalization system, tests, and documentation.

Last edited 13 months ago by LiquidPL (previous) (diff)

comment:18 Changed 13 months ago by timgraham

Created a django-developers thread to ask if a new setting is fine for this.

comment:19 Changed 12 months ago by timgraham

  • Patch needs improvement set

Claude proposed a way to avoid adding a new setting on the django-developers thread. Marking as "Patch needs improvement" in light of that.

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