webrecorder / pywb

Core Python Web Archiving Toolkit for replay and recording of web archives
https://pypi.python.org/pypi/pywb
GNU General Public License v3.0
1.42k stars 217 forks source link

Fixes switch_locale not adding locale if missing from URL #871

Closed Quirinus closed 1 year ago

Quirinus commented 1 year ago

If the language code was missing in the URI, switch_locale(locale) didn't add it (it worked fine if it was present). That means that it produced the same URL for all locales, each missing the language code in the URL.

Description

I added an additional check that checks if the language is set in the URI, and it is changed only in that case. Otherwise if it was missing, it was producing a URL that doesn't contain it - but now it does add the launguage code to the URL if it was missing.

Motivation and Context

Fixes #870

Screenshots (if appropriate):

image

Notice the current URL for a collection named "test" (not containing any language code in the URL). I hovered the mouse over the link to change the locale to "hr" (top right), and the URL that is in that link is shown on bottom left - it doesn't contain "hr". Same happens when I hover over "en".

Types of changes

Checklist:

I don't know how to run the tests.

Quirinus commented 1 year ago

I tested this using the default web server ("wayback" command). Hopefully it works well with uwsgi too.

I will check if I have time.