mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02: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
|
end
|
||||||
|
|
||||||
def request_locale
|
def request_locale
|
||||||
preferred_locale || compatible_locale
|
http_accept_language.language_region_compatible_from(I18n.available_locales)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -55,8 +55,8 @@ module Mastodon
|
|||||||
:el,
|
:el,
|
||||||
:en,
|
:en,
|
||||||
:eo,
|
:eo,
|
||||||
:'es-AR',
|
|
||||||
:es,
|
:es,
|
||||||
|
:'es-AR',
|
||||||
:et,
|
:et,
|
||||||
:eu,
|
:eu,
|
||||||
:fa,
|
:fa,
|
||||||
@ -97,8 +97,8 @@ module Mastodon
|
|||||||
:sk,
|
:sk,
|
||||||
:sl,
|
:sl,
|
||||||
:sq,
|
:sq,
|
||||||
:'sr-Latn',
|
|
||||||
:sr,
|
:sr,
|
||||||
|
:'sr-Latn',
|
||||||
:sv,
|
:sv,
|
||||||
:ta,
|
:ta,
|
||||||
:te,
|
:te,
|
||||||
|
@ -16,10 +16,16 @@ describe ApplicationController, type: :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
shared_examples 'default locale' do
|
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
|
it 'sets available and preferred language' do
|
||||||
request.headers['Accept-Language'] = 'ca-ES, fa'
|
request.headers['Accept-Language'] = 'ca-ES, fa'
|
||||||
get 'success'
|
get 'success'
|
||||||
expect(response.body).to eq 'fa'
|
expect(response.body).to eq 'ca'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets available and compatible language if none of available languages are preferred' do
|
it 'sets available and compatible language if none of available languages are preferred' do
|
||||||
|
Loading…
Reference in New Issue
Block a user