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

Set user language from browser header if no cookie is available #242

Open
Bertware opened this issue Oct 21, 2016 · 4 comments
Open

Set user language from browser header if no cookie is available #242

Bertware opened this issue Oct 21, 2016 · 4 comments

Comments

@Bertware
Copy link
Member

The language selection is an additional screen between navigating to irail.be and performing a search. Selecting a language takes almost as long as taking a train, the language selection is intrusive and does not feel really user-friendly

Current situation:

  • Visit irail.be for the first time, or with cleared cookies.
  • Language selection is shown. The user needs to select a language before he can search for trains.
  • User selects language and continues.

Proposed improvement:

  • Visit irail.be for the first time, or with cleared cookies.
  • Language is deducted from Accept-Language header. If Dutch or French is not found in the header, English is used as fall-back.
  • User can instantly search for trains
  • (optional) a notification bar is shown asking the user if he wants to change his language. This does not hinder searching for trains

When the user has already visited irail.be, the previous language is used. (This is already the case)

@Haroenv
Copy link
Member

Haroenv commented Oct 21, 2016

There's also the navigator.language(s) that can be used (https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language)

@pietercolpaert
Copy link
Member

pietercolpaert commented Nov 24, 2016

Also, we should move away from this laravel session thing. It's really awkward... We should be able to just use a cookie for this imo.

Can we fix this? I like the proposal of @Bertware in each case!

@Haroenv
Copy link
Member

Haroenv commented Nov 24, 2016

https://github.com/iRail/hyperRail/blob/master/app/Http/Middleware/Language.php#L32 should be appended with $request->server('HTTP_ACCEPT_LANGUAGE'); (and then be parsed)

@Bertware
Copy link
Member Author

Bertware commented Dec 6, 2016

This functionality was implemented using locale_lookup. This means the php_intl module is required. This function was chosen as it implements the search protocol for languages and keeps the weights in mind.
http://php.net/manual/en/locale.lookup.php

Note:
Users can change between languages using the "Language" link on the bottom of the page. This link was already there. However, this link is always shown in the current language, meaning an Englishman looking at the site won't recognize it if it's in Dutch for some reason. Since there are only 3 languages, maybe this could be changed to "Nederlands - Francais - English". Or maybe it could be in a more visible place? (e.g. flags in the header)

Bertware added a commit to Bertware/hyperRail that referenced this issue Jan 15, 2017
Added tests for language, special cases.
Fixed broken tests iRail#253
Bertware added a commit that referenced this issue Sep 22, 2017
Set language from browser, accept enter key in planner #242 #243
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

3 participants