[Django] #35691: Override translation

10 views
Skip to first unread message

Django

unread,
Aug 19, 2024, 8:21:55 AM8/19/24
to django-...@googlegroups.com
#35691: Override translation
-------------------------------------+-------------------------------------
Reporter: Omid Shojaee | Type: Bug
Status: new | Component:
| Internationalization
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Hello,

I've asked this in the Forum and SO and there was no solution which leads
me to believe that this is a bug.

Let's say I want to translate a phrase already translated. This is a
matter of personal preference so I don't want to go to Transifex.

First I find the existing translation:

{{{#!python
# .venv\Lib\site-packages\filebrowser\locale\fa\LC_MESSAGES\django.po

#: sites.py:348 templates/filebrowser/include/breadcrumbs.html:9
#: templates/filebrowser/include/breadcrumbs.html:11
msgid "FileBrowser"
msgstr "فایل‌بروز"
}}}

Then I create an app called `core`, a file called `translations.py` and
add this to it:

{{{#!python
from django.utils.translation import gettext

gettext('FileBrowser')
}}}

Now I make messages and find the phrase in the `.po` file and translate
it:

{{{#!shell
#: .\core\translations.py:3
msgid "FileBrowser"
msgstr "مدیریت فایل"
}}}

After compiling the messages, I still see the original translation and not
my own.

Perhaps the order of apps is important so I put my `core` app before
`filebrowser` in the settings but still get the same result.

Therefore, either overriding translations is not possible, or this is a
bug.
--
Ticket URL: <https://code.djangoproject.com/ticket/35691>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 19, 2024, 8:41:27 AM8/19/24
to django-...@googlegroups.com
#35691: Override translation
-------------------------------------+-------------------------------------
Reporter: Omid Shojaee | Owner: (none)
Type: Bug | Status: closed
Component: | Version: 5.1
Internationalization |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* resolution: => invalid
* status: new => closed

Comment:

Hello Omid, thank you for your ticket. Is
[https://forum.djangoproject.com/t/how-to-re-translate-django/26683/ this
your post]? I see many replies from Claude. There are also various search
results that provide solutions to your issue, specifically
[https://stackoverflow.com/questions/7878028/override-default-django-
translations this one].

I honestly don't think this is a bug in Django, overriding Django
translations feels like a niche use case and there a ways to do this. I
don't think this applies to the broader ecosystem, and Django is a
framework designed to offer robust and accurate solutions for common
scenarios.

If you are certain that the solutions suggested in the links above do not
work, please reopen the ticket and provide a minimal Django reproducer for
us to replicate. Until then, I'll close the ticket accordingly.
--
Ticket URL: <https://code.djangoproject.com/ticket/35691#comment:1>

Django

unread,
Aug 19, 2024, 11:45:50 AM8/19/24
to django-...@googlegroups.com
#35691: Override translation
-------------------------------------+-------------------------------------
Reporter: Omid Shojaee | Owner: (none)
Type: Bug | Status: closed
Component: | Version: 5.1
Internationalization |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Omid Shojaee):

As I mentioned, yes that's my forum post and my last reply says the
solution provided by Claude didn't work.

Also, the steps I described above is exactly the same as the answer to the
SO post you linked to: https://stackoverflow.com/a/20439571/14442010 which
didn't work either (perhaps because it's 11 years old and something is
changed since then).

Steps to reproduce is very simple: Just install Django and try the
solution provided in the SO.
--
Ticket URL: <https://code.djangoproject.com/ticket/35691#comment:2>

Django

unread,
Aug 19, 2024, 2:21:11 PM8/19/24
to django-...@googlegroups.com
#35691: Override translation
-------------------------------------+-------------------------------------
Reporter: Omid Shojaee | Owner: (none)
Type: Bug | Status: closed
Component: | Version: 5.1
Internationalization |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Claude Paroz):

Omid, like Natalia said, I guess the best way to go forward is to provide
a sample project that reproduces your issue. Then post it or a link to it
on the forum and we can continue talking there.
--
Ticket URL: <https://code.djangoproject.com/ticket/35691#comment:3>

Django

unread,
Aug 19, 2024, 2:29:50 PM8/19/24
to django-...@googlegroups.com
#35691: Override translation
-------------------------------------+-------------------------------------
Reporter: Omid Shojaee | Owner: (none)
Type: Bug | Status: closed
Component: | Version: 5.1
Internationalization |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Omid Shojaee):

I don't know how to do that because you need to have access to the source
code to examine the issue. Is there any online platform for that?
--
Ticket URL: <https://code.djangoproject.com/ticket/35691#comment:4>

Django

unread,
Aug 19, 2024, 2:49:08 PM8/19/24
to django-...@googlegroups.com
#35691: Override translation
-------------------------------------+-------------------------------------
Reporter: Omid Shojaee | Owner: (none)
Type: Bug | Status: closed
Component: | Version: 5.1
Internationalization |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Claude Paroz):

The idea would be to create the smallest possible project where a similar
issue can be reproduced. You may also put your project on a hosting
platform like GitHub or GitLab, but depending on the complexity of your
project, you can only hope (but not expect) that anyone will spend the
time to configure it locally.
--
Ticket URL: <https://code.djangoproject.com/ticket/35691#comment:5>
Reply all
Reply to author
Forward
0 new messages