Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
4bcef12b
Unverified
Commit
4bcef12b
authored
4 years ago
by
ThibG
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix sr locale being selected over sr-Latn (#13693)
* Fix sr locale being selected over sr-Latn * Update tests
parent
4b2d9b8a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/concerns/localized.rb
+1
-13
1 addition, 13 deletions
app/controllers/concerns/localized.rb
config/application.rb
+2
-2
2 additions, 2 deletions
config/application.rb
spec/controllers/concerns/localized_spec.rb
+7
-1
7 additions, 1 deletion
spec/controllers/concerns/localized_spec.rb
with
10 additions
and
16 deletions
app/controllers/concerns/localized.rb
+
1
−
13
View file @
4bcef12b
...
...
@@ -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
This diff is collapsed.
Click to expand it.
config/application.rb
+
2
−
2
View file @
4bcef12b
...
...
@@ -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
,
...
...
This diff is collapsed.
Click to expand it.
spec/controllers/concerns/localized_spec.rb
+
7
−
1
View file @
4bcef12b
...
...
@@ -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
'
f
a'
expect
(
response
.
body
).
to
eq
'
c
a'
end
it
'sets available and compatible language if none of available languages are preferred'
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment