Skip to content

Commit

Permalink
Merge pull request #907 from alphagov/respond-to-en-gb-locales
Browse files Browse the repository at this point in the history
Fall back to "en" locale for "en-GB"
  • Loading branch information
tijmenb authored Feb 22, 2017
2 parents f031a78 + 43dffd5 commit 5a3a0d8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/root_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def govuk_available_locales
end

def govuk_locales
# Smart Answers uses "en-GB" instead of "en". We don't have a specfic en-GB
# locale for the components. This will make return the English locale since
# it's a reasonable fallback.
params[:locale] = "en" if params[:locale] == "en-GB"

return error_404 unless params[:locale].match(/^[a-z]{2}(-[a-z0-9]{2,3})?$/)
locale_file_path = Rails.root.join("config", "locales", "#{params[:locale]}.yml")
render_yaml_as_json(locale_file_path)
Expand Down

0 comments on commit 5a3a0d8

Please sign in to comment.