Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXCLUDED_APPLICATIONS settings #292

Open
hovi opened this issue Jun 29, 2024 · 4 comments
Open

EXCLUDED_APPLICATIONS settings #292

hovi opened this issue Jun 29, 2024 · 4 comments

Comments

@hovi
Copy link

hovi commented Jun 29, 2024

  • Which version of Django are you using?: 5.0.4
  • Which version of django-rosetta are you using?: 0.10.0
  • Have you looked trough recent issues and checked this isn't a duplicate? I did!

I am trying to use this settings, but whatever I try, I see no effect. I see there are unit tests and they are working so everything seems fine.
I even literally tried:

ROSETTA_EXCLUDED_APPLICATIONS = INSTALLED_APPS

But whatever I do, I see in the list all the translation files of all the apps. Anything obvious I am doing wrong?

@mbi
Copy link
Owner

mbi commented Jun 30, 2024

Yes, I agree that the way we currently find discover locale paths is too aggressive: we essentially try to find all possible locations for PO files using

  1. Django's app catalog
  2. by scanning the local project root and
  3. looking in settings.LOCALE_PATHS.

We only exclude applications from the first list, but if for some reason your app also matches 2 or 3, we can't easily detect that.

Also, you might want to try using ROSETTA_EXCLUDED_PATHS instead, e.g.

ROSETTA_EXCLUDED_PATHS = ("/home/marco/Code/django-rosetta/testproject/locale",)

Will exclude this:
image

@hovi
Copy link
Author

hovi commented Jun 30, 2024

Thanks for reply.
In the end, I simply want only to translate my local apps and nothing else. Of course the best would be to have a boolean settings that allow me to filter that.

I read about EXCLUDED_PATHS, but the fact that it has to be absolute makes it much less usable.

Nonetheless, I don't see why EXCLUDED_APPS shouldn't work, any idea why it doesn't?

@mbi
Copy link
Owner

mbi commented Jun 30, 2024

Nonetheless, I don't see why EXCLUDED_APPS shouldn't work, any idea why it doesn't?

Yes, as I mentioned above we look for catalogs by app (in which case the exclusion works) and by various other means (not necessarily by app) in which cases EXCLUDED_APPS doesn't have any effect.

The relevant bit of code is here: https://github.com/mbi/django-rosetta/blob/develop/rosetta/poutil.py#L33 if you'd like to take a closer look. Pull requests are as always welcome. 🙏

@hovi
Copy link
Author

hovi commented Jun 30, 2024

Thanks, and is this supposed to be expected behaviour?

Looking deeper into the code, I basically only want "project" po_filter:

if po_filter not in {"all", "django", "third-party", "project"}:

I don't want people to see or translate third party or django apps at this point. We really translate only our frontend and don't need this. This would only confuse translators + it unnecessarily gives out sensitive information about project paths on the server.

What would you say to making this settings configurable? {"all", "django", "third-party", "project"}
If you are positive about it, what changes would that involve besides getting this from settings + changes in template?

Lastly, I was trying to run tests and play with it very slightly and some tests were failing, I haven't found any instructions on how to set it up, is there a doc? It may be some external component missing that I don't have installed, I really haven't looked much into that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants