From d2682f9ed0f98e03b1a370b9c4b02c8deed6a7d3 Mon Sep 17 00:00:00 2001 From: Stephen Margheim Date: Fri, 16 Oct 2026 12:27:36 +0200 Subject: [PATCH 1/2] Render the dashboard in apps that don't make English available The dashboard forced the :en locale, which raises I18n::InvalidLocale when an app's available_locales leaves English out. It now keeps the app's locale in that case. Fixes #70. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../solid_errors/errors_controller.rb | 7 +++++-- .../solid_errors/errors_controller_test.rb | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/controllers/solid_errors/errors_controller.rb b/app/controllers/solid_errors/errors_controller.rb index 8703cf3..e078648 100644 --- a/app/controllers/solid_errors/errors_controller.rb +++ b/app/controllers/solid_errors/errors_controller.rb @@ -1,6 +1,6 @@ module SolidErrors class ErrorsController < ApplicationController - around_action :force_english_locale! + around_action :use_english_when_available before_action :set_error, only: %i[show update destroy] @@ -53,7 +53,10 @@ def set_error @error = Error.find(params[:id]) end - def force_english_locale!(&action) + # The dashboard's strings ship in English only; apps that don't allow :en keep their own locale + def use_english_when_available(&action) + return action.call unless I18n.locale_available?(:en) + I18n.with_locale(:en, &action) end diff --git a/test/controllers/solid_errors/errors_controller_test.rb b/test/controllers/solid_errors/errors_controller_test.rb index df9d314..14a43b7 100644 --- a/test/controllers/solid_errors/errors_controller_test.rb +++ b/test/controllers/solid_errors/errors_controller_test.rb @@ -85,6 +85,22 @@ class SolidErrors::ErrorsControllerTest < ActionDispatch::IntegrationTest assert_select "main a[href='/']", text: "← Back to main app" end + test "the dashboard renders in apps that do not make English available" do + available_locales, default_locale, locale = I18n.available_locales, I18n.default_locale, I18n.locale + I18n.available_locales = [:fr] + I18n.default_locale = I18n.locale = :fr + + get solid_errors.errors_path + assert_response :success + + get solid_errors.error_path(@error) + assert_response :success + ensure + I18n.available_locales = available_locales + I18n.default_locale = default_locale + I18n.locale = locale + end + private def report_errors(count) From fb13a296ff47cf0125a1a3f48340c3143194e45f Mon Sep 17 00:00:00 2001 From: Stephen Margheim Date: Fri, 16 Oct 2026 12:27:50 +0200 Subject: [PATCH 2/2] Document how the dashboard picks its locale Co-Authored-By: Claude Opus 5.5 (1M context) --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 8332469..e4f9f8b 100644 --- a/README.md +++ b/README.md @@ -412,6 +412,11 @@ You can always take control of the views by creating your own views and/or parti ``` + +### Locales + +The dashboard is written in English and renders in English whenever your app allows the `:en` locale. If `config.i18n.available_locales` leaves out `:en`, the dashboard renders in your app's locale instead, and you will need to provide the `datetime.distance_in_words.short` translations from [`config/locales/en.yml`](config/locales/en.yml) in that locale. + ## Sponsors