Enhance language selection and detection with pagination fixes#632
Merged
Conversation
Replace the old <select> language picker with a Bootstrap-style dropdown menu and add scoped CSS for hover/active states. Keep existing URL GET parameters when changing language by outputting them as hidden inputs in a small form (id=changelanguage) and submit that form on selection; default to "en" if the requested lang folder is missing. Also add HTML-escaping for injected values, assign ids to hidden lang input and form, and simplify the JS submission via onclick handlers. This improves UX and preserves user context when switching languages.
Replace the previous simple language selection with a robust detection flow: dynamically scan opac_conf for installed languages, prefer explicit ?lang in URL, then session/cookie, then browser Accept-Language, then central session, and finally opac_gdef or English as fallback. Adds setcookie and session/request synchronization, verifies language folders exist before selecting, and provides a safety default list if the directory scan fails (e.g. due to permissions). Removes the old priority logic and final directory validation in favor of the new consolidated selection process.
Add a safeguard when paginated results are empty (e.g. due to bots) by checking resultados_pagina_atual[0]['base'] and falling back to a safe default base. Standardize and correct several comments (Portuguese→English), fix quote characters, update changelog entry, and adjust some user-facing default strings to English fallbacks. Also clarify dictionary/truncation logic comments and minor wording tweaks; no major behavior changes beyond the pagination safety check and messaging/comment cleanup.
Comment out the error_log call that recorded attempts with unknown request parameters to reduce log noise (or avoid exposing data). The handler still blocks the request by terminating execution when an invalid parameter is detected. The line has not been removed, as it may be useful for debugging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users have reported a number of issues, mainly regarding language selection, since version 3.6.0.