Opened 11 years ago

Last modified 5 weeks ago

#6376 assigned New feature

Allow using custom gettext domains

Reported by: dennis@… Owned by: Rui Pereira
Component: Internationalization Version: master
Severity: Normal Keywords: gettext
Cc: clouserw@…, fwenzel, 4glitch@…, raymond.penners@…, Krzysztof Gutkowski 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@… 11 years ago.
SImple and untested patch

Download all attachments as: .zip

Change History (22)

Changed 11 years ago by dennis@…

Attachment: gettext_domain.patch added

SImple and untested patch

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

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 11 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 11 years ago by Simon Greenhill <dev@…>

Has patch: set
Patch needs improvement: set
Triage Stage: UnreviewedDesign decision needed

comment:4 Changed 11 years ago by Malcolm Tredinnick

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 11 years ago by Malcolm Tredinnick

Triage Stage: Design decision neededSomeday/Maybe

comment:6 Changed 9 years ago by Wil Clouser

Cc: clouserw@… added

comment:7 Changed 8 years ago by Julien Phalip

Severity: Normal
Type: New feature

comment:8 Changed 8 years ago by Julien Phalip

Needs tests: set

comment:9 Changed 8 years ago by fwenzel

Cc: fwenzel added
Easy pickings: unset

comment:10 Changed 8 years ago by fwenzel

Easy pickings: set

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

comment:11 Changed 8 years ago by Jannis Leidel

Easy pickings: unset

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

comment:12 Changed 7 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:13 Changed 6 years ago by Ramiro Morales

Triage Stage: Someday/MaybeAccepted

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

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

Cc: 4glitch@… added

comment:15 Changed 5 years ago by Raymond Penners

Cc: raymond.penners@… added

comment:16 Changed 4 years ago by Krzysztof Gutkowski

Cc: Krzysztof Gutkowski added
Has patch: unset
Owner: changed from nobody to Krzysztof Gutkowski
Patch needs improvement: unset
Status: newassigned

comment:17 Changed 4 years ago by Krzysztof Gutkowski

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 4 years ago by Krzysztof Gutkowski (previous) (diff)

comment:18 Changed 4 years ago by Tim Graham

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

comment:19 Changed 4 years ago by Tim Graham

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.

comment:20 Changed 4 months ago by Rui Pereira

Owner: changed from Krzysztof Gutkowski to Rui Pereira
Patch needs improvement: unset

comment:21 Changed 5 weeks ago by Tim Graham

Patch needs improvement: set
Summary: Please don't force the usage of the 'django' gettext domainAllow using custom gettext domains
Note: See TracTickets for help on using tickets.
Back to Top