mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-21 08:39:44 +00:00
Fix sr locale being selected over sr-Latn (#13693)
* Fix sr locale being selected over sr-Latn * Update tests
This commit is contained in:
parent
4b2d9b8a55
commit
4bcef12bad
|
@ -28,18 +28,6 @@ module Localized
|
|||
end
|
||||
|
||||
def request_locale
|
||||
preferred_locale || compatible_locale
|
||||
end
|
||||
|
||||
def preferred_locale
|
||||
http_accept_language.preferred_language_from(available_locales)
|
||||
end
|
||||
|
||||
def compatible_locale
|
||||
http_accept_language.compatible_language_from(available_locales)
|
||||
end
|
||||
|
||||
def available_locales
|
||||
I18n.available_locales.reverse
|
||||
http_accept_language.language_region_compatible_from(I18n.available_locales)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,8 +55,8 @@ module Mastodon
|
|||
:el,
|
||||
:en,
|
||||
:eo,
|
||||
:'es-AR',
|
||||
:es,
|
||||
:'es-AR',
|
||||
:et,
|
||||
:eu,
|
||||
:fa,
|
||||
|
@ -97,8 +97,8 @@ module Mastodon
|
|||
:sk,
|
||||
:sl,
|
||||
:sq,
|
||||
:'sr-Latn',
|
||||
:sr,
|
||||
:'sr-Latn',
|
||||
:sv,
|
||||
:ta,
|
||||
:te,
|
||||
|
|
|
@ -16,10 +16,16 @@ describe ApplicationController, type: :controller do
|
|||
end
|
||||
|
||||
shared_examples 'default locale' do
|
||||
it 'sets available and preferred language' do
|
||||
request.headers['Accept-Language'] = 'sr-Latn'
|
||||
get 'success'
|
||||
expect(response.body).to eq 'sr-Latn'
|
||||
end
|
||||
|
||||
it 'sets available and preferred language' do
|
||||
request.headers['Accept-Language'] = 'ca-ES, fa'
|
||||
get 'success'
|
||||
expect(response.body).to eq 'fa'
|
||||
expect(response.body).to eq 'ca'
|
||||
end
|
||||
|
||||
it 'sets available and compatible language if none of available languages are preferred' do
|
||||
|
|
Loading…
Reference in a new issue