-
Notifications
You must be signed in to change notification settings - Fork 0
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
Parse locale from Accept-Language HTTP header #92
Conversation
get test_path, params: {}, env: { 'HTTP_ACCEPT_LANGUAGE' => 'de-CH, en-US, fr' } | ||
assert_equal 'fr', response.body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attention: no partial matches, only exact ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be OK for us, since we can control the request headers.
config/application.rb
Outdated
@@ -32,5 +32,9 @@ class Application < Rails::Application | |||
config.api_only = true | |||
|
|||
config.time_zone = 'UTC' | |||
|
|||
config.i18n.available_locales = [:de, :en, :fr, :it, :rm] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand the code correctly, the option for swiss-german is missing. Could it be added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How? What's the appropriate HTTP_ACCEPT_LANGUAGE header for schweizerdeutsch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This site says it would be "de-ch". Using the ISO 639-1 up-to ISO 639-3 would be "gsw". Another possibility could be just "ch" to match the style of the others, but I'm really not familiar with how this is usually handled 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
de-CH
is german in Switzerland. That's for sure not what you intend. In BCP47's RFCs I didn't find any mapping to ISO, so I think gsw
is the correct one according to the IANA tag list: http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a small comment about the option for swiss-german, otherwise looking good. But I'm not very familiar with rails, maybe add @dbrgn also as a reviewer 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but it would be nice if :gsw could be added as well.
Fixes #78
(no effect though, because we don't have any translated content yet)