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

Add "locale=" URL parameter to the webapp (prepares for adding a locale switcher) #585

Closed

Conversation

DeeDeeG
Copy link
Contributor

@DeeDeeG DeeDeeG commented Apr 27, 2019

Context

Summary of Changes

  • Add a ?locale=[locale] default URL parameter to all dynamically-generated links, e.g. links made with the Rails link_helper
  • Adjust locale selection to, during page load, look for this ?locale= parameter, and if present, use that parameter's string as the locale.
    • (Thus far, locale has only been set from the user's browser locale preference list. There has been no way to specify what language Refuge appears in beside editing the browser locale preferences.)
      • Code in this PR still falls back to the browser locale list if no ?locale= parameter is present in the URL.
  • Initial attempt to track down hard-coded links or redirects, and replace with dynamically generated ones such as with Rails link_helper code.
    • So far only adjusted the main homepage link in the far corner of the topnav area.
    • The search box still redirects in a way that does not include the ?locale= parameter at this time.
      • This should be fixed, or else the search box will break the ?locale= chain, and make a language switcher seem "broken" and be much less useful.

Checklist

  • Tested Mobile Responsiveness
  • Added Unit Tests
  • CI Passes
  • Deploys to Heroku on test Correctly (Maintainers will handle)
  • Added Documentation (Service and Code when required)

Screenshots

Before

After

@DeeDeeG DeeDeeG changed the title Language switcher april 2019 Add "locale=" URL parameter to the webapp (prepares for adding a locale switcher) Apr 27, 2019
@DeeDeeG DeeDeeG force-pushed the language-switcher-April-2019 branch 3 times, most recently from 2d6fd7b to b92bc5f Compare July 1, 2019 23:57
Adds a :locale parameter (which should come from the URL, e.g.:
`refugerestrooms.org/?locale=en` or something like that.)
Allows URLs auto-generated by Rails to automatically be expanded
to include "?locale=xyz" or "&locale=xyz"

For example, this affects URLs made with ActionView URL helpers
('button_to', 'link_to', etc.)

See: https://api.rubyonrails.org/v5.2.3/classes/ActionView/Helpers/UrlHelper.html

(Hard-coded URLS will generally not get the parameter added.)
Use a link_to helper to dynamically create the homepage link,
because URL helpers now automatically include the 'locale=' parameter.
@DeeDeeG DeeDeeG force-pushed the language-switcher-April-2019 branch 4 times, most recently from 7e77561 to 5656377 Compare July 2, 2019 04:32
@DeeDeeG
Copy link
Contributor Author

DeeDeeG commented Oct 26, 2019

See this documentation for details: https://guides.rubyonrails.org/i18n.html#managing-the-locale-across-requests

There may be a nicer way to do this, i.e. with sub-directories for each locale: https://refugerestrooms.org/en/, https://refugerestrooms.org/es/, https://refugerestrooms.org/pl/ etc.

@DeeDeeG DeeDeeG mentioned this pull request Apr 10, 2020
5 tasks
@DeeDeeG
Copy link
Contributor Author

DeeDeeG commented Apr 16, 2020

Closed by #620. 🎉

@DeeDeeG DeeDeeG closed this Apr 16, 2020
@DeeDeeG DeeDeeG mentioned this pull request Nov 4, 2020
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant