Skip to content

request.accept_language.best_match will be deprecated #17969

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

Open
di opened this issue Apr 15, 2025 · 2 comments
Open

request.accept_language.best_match will be deprecated #17969

di opened this issue Apr 15, 2025 · 2 comments
Labels
bug 🐛 translation Issues relating to PyPI translations

Comments

@di
Copy link
Member

di commented Apr 15, 2025

Per https://github.com/Pylons/webob/blob/39d5af3c797e7b867f152c2e8c979de42d029403/src/webob/acceptparse.py#L4358-L4374:

This is currently maintained for backward compatibility, and will be
deprecated in the future.

We may want to replace this with request.accept_language.lookup instead.

A potential issue is that at https://github.com/pypi/infra/blob/d5374e6e92f5a09729d649a0a587935d19f2d76f/terraform/warehouse/vcl/main.vcl#L168 we use the language_lookup function, this might behave slightly differently than best_match or slightly differently than lookup (unsure). The former might result in a current bug, and the latter might produce a bug if we use lookup instead, in which the locale we negotiate differs from what we set in VCL.

@di di added bug 🐛 translation Issues relating to PyPI translations labels Apr 15, 2025
@di
Copy link
Member Author

di commented Apr 18, 2025

Additionally, the locale negotiation on the backend might be unnecessary in most cases: if we just use the PyPI-Locale header set by Fastly (assuming this is set for all requests, cached &. uncached) then it should be sufficient.

However, we have some endpoints (like upload.pypi.org) that bypass Fastly and locale negotiation needs to happen on the backend. In those cases, it should fall back to what we have now.

Regardless, all translated views should write PyPI-Locale on the response to the singular negotiated locale value of the content served, ensure that we don't add mis-translated cache entries.

Additionally, VCL needs to ensure that any value it sets to PyPI-Locale is a known locale, otherwise this can be set to any arbitrary value.

@miketheman
Copy link
Member

Related, see Pylons/webob#460 for work gone in to reimplement best_match

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 translation Issues relating to PyPI translations
Projects
None yet
Development

No branches or pull requests

2 participants