Skip to content

Commit

Permalink
Fall back to "en" locale for "en-GB"
Browse files Browse the repository at this point in the history
Smart answers uses a "en-GB" locale, but we don't have
that in the app. This causes a lot of 404's to be returned
and missing translations in smart answers (presumably).
  • Loading branch information
tijmenb committed Feb 22, 2017
1 parent 1b6a884 commit 43dffd5
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 43dffd5

Please sign in to comment.