Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#35691 closed Bug (invalid)

Override translation

Reported by: Omid Shojaee Owned by:
Component: Internationalization Version: 5.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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:

# .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:

from django.utils.translation import gettext

gettext('FileBrowser')

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

#: .\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.

Change History (5)

comment:1 by Natalia Bidart, 4 months ago

Resolution: invalid
Status: newclosed

Hello Omid, thank you for your ticket. Is this your post? I see many replies from Claude. There are also various search results that provide solutions to your issue, specifically 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.

comment:2 by Omid Shojaee, 4 months ago

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.

comment:3 by Claude Paroz, 4 months ago

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.

comment:4 by Omid Shojaee, 4 months ago

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?

comment:5 by Claude Paroz, 4 months ago

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.

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