A platform for community discussion. Free, open, simple.
Add extra locales to bootstrap.json
Robin Ward19763065394e
diff --git a/app/controllers/bootstrap_controller.rb b/app/controllers/bootstrap_controller.rbindex 146e89266d9..c7822b453b1 100644--- a/app/controllers/bootstrap_controller.rb+++ b/app/controllers/bootstrap_controller.rb@@ -34,6 +34,14 @@ class BootstrapController < ApplicationControllerendadd_style(mobile_view? ? :mobile_theme : :desktop_theme) if theme_ids.present?+ extra_locales = []+ if ExtraLocalesController.client_overrides_exist?+ extra_locales << ExtraLocalesController.url('overrides')+ end+ if staff?+ extra_locales << ExtraLocalesController.url('admin')+ end+bootstrap = {theme_ids: theme_ids,title: SiteSetting.title,@@ -41,8 +49,9 @@ class BootstrapController < ApplicationControllerlocale_script: locale,stylesheets: @stylesheets,setup_data: client_side_setup_data,- preloaded: @preloaded+ preloaded: @preloaded,}+ bootstrap[:extra_locales] = extra_locales if extra_locales.present?render_json_dump(bootstrap: bootstrap)enddiff --git a/spec/requests/bootstrap_controller_spec.rb b/spec/requests/bootstrap_controller_spec.rbindex 9b1725420f1..4cd735351d1 100644--- a/spec/requests/bootstrap_controller_spec.rb+++ b/spec/requests/bootstrap_controller_spec.rb@@ -39,4 +39,16 @@ describe BootstrapController doexpect(preloaded['topicTrackingStates']).to be_presentend+ it "returns extra locales (admin) when staff" do+ user = Fabricate(:admin)+ sign_in(user)+ get "/bootstrap.json"+ expect(response.status).to eq(200)++ json = response.parsed_body+ expect(json).to be_present++ bootstrap = json['bootstrap']+ expect(bootstrap['extra_locales']).to be_present+ endend