From fae1382c8deb3b8662f1257b1465c81bf823e604 Mon Sep 17 00:00:00 2001 From: AyakorK Date: Fri, 3 Nov 2023 14:27:59 +0100 Subject: [PATCH] Add a default cookie for the translation to appear when no translation had been selected --- app/helpers/application_helper.rb | 5 +++++ app/views/layouts/decidim/_head_extra.html.erb | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 66eb878..cf8aca4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,5 +60,10 @@ def auto_target_language if Rails.application.secrets.dig(:decidim, :translation_mode).to_sym == :both && response.headers["content-language"].present? response.headers["content-language"].split("-").first end + + if translation_mode?(:google) + default_trad = Rails.configuration.i18n.default_locale.to_s + cookies[:googtrans] ||= { value: "/auto/#{default_trad}", expires: 1.year.from_now } + end end end diff --git a/app/views/layouts/decidim/_head_extra.html.erb b/app/views/layouts/decidim/_head_extra.html.erb index 0e63e07..bd914e5 100644 --- a/app/views/layouts/decidim/_head_extra.html.erb +++ b/app/views/layouts/decidim/_head_extra.html.erb @@ -8,8 +8,6 @@ <% end %> <% if translation_mode?(:google) %>