From ae53dbd8ecf1e5e7635207ca32d7fd40f6928e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com> Date: Fri, 16 Dec 2022 16:37:15 +0100 Subject: [PATCH] get default language instead of first language of website --- app/models/communication/website/menu.rb | 2 +- app/models/communication/website/page/with_path.rb | 4 ++-- app/models/communication/website/permalink.rb | 2 +- app/models/concerns/with_git.rb | 2 +- .../websites/configs/development_config/static.html.erb | 2 +- .../websites/configs/production_config/static.html.erb | 7 ++----- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/models/communication/website/menu.rb b/app/models/communication/website/menu.rb index 6317937ec..4b5ca387c 100644 --- a/app/models/communication/website/menu.rb +++ b/app/models/communication/website/menu.rb @@ -41,7 +41,7 @@ class Communication::Website::Menu < ApplicationRecord def git_path(website) # TODO I18n : Right now, we use the language of the website. Add a language to the menu (and future translations) path = "data/menus/" - path += "#{website.languages.first.iso_code}/" if website.languages.any? + path += "#{website.default_language.iso_code}/" if website.languages.any? "#{path}#{identifier}.yml" end diff --git a/app/models/communication/website/page/with_path.rb b/app/models/communication/website/page/with_path.rb index 1809109d1..0b860794e 100644 --- a/app/models/communication/website/page/with_path.rb +++ b/app/models/communication/website/page/with_path.rb @@ -20,9 +20,9 @@ module Communication::Website::Page::WithPath path = '' # TODO i18n remplacer le choix de la langue if website.languages.many? - path += "/fr" + path += "/fr" elsif website.languages.any? - path += "/#{website.languages.first.iso_code}" + path += "/#{website.default_language.iso_code}" end path += "/#{slug_with_ancestors}/" path.gsub(/\/+/, '/') diff --git a/app/models/communication/website/permalink.rb b/app/models/communication/website/permalink.rb index d3bcc73b5..69223ec04 100644 --- a/app/models/communication/website/permalink.rb +++ b/app/models/communication/website/permalink.rb @@ -107,7 +107,7 @@ class Communication::Website::Permalink < ApplicationRecord def published_path # TODO I18n doit prendre la langue du about p = "" - p += "/#{website.languages.first.iso_code}" if website.languages.any? + p += "/#{website.default_language.iso_code}" if website.languages.any? p += pattern substitutions.each do |key, value| p.gsub! ":#{key}", "#{value}" diff --git a/app/models/concerns/with_git.rb b/app/models/concerns/with_git.rb index be5ea940b..02eea6703 100644 --- a/app/models/concerns/with_git.rb +++ b/app/models/concerns/with_git.rb @@ -20,7 +20,7 @@ module WithGit # todo totalement arbitraire path += "fr/" elsif website.languages.any? - path += "#{website.languages.first.iso_code}/" + path += "#{website.default_language.iso_code}/" end path end diff --git a/app/views/admin/communication/websites/configs/development_config/static.html.erb b/app/views/admin/communication/websites/configs/development_config/static.html.erb index 68dc1a112..378d0a376 100644 --- a/app/views/admin/communication/websites/configs/development_config/static.html.erb +++ b/app/views/admin/communication/websites/configs/development_config/static.html.erb @@ -1,5 +1,5 @@ # DO NOT EDIT THIS FILE BY HAND - IT WILL BE OVERWRITTEN BY OSUNY <%# TODO I18n: Add "Default language" in Communication::Website %> -defaultContentLanguage: <%= @website.languages.first.iso_code %> +defaultContentLanguage: <%= @website.default_language.iso_code %> defaultContentLanguageInSubdir: <%= @website.languages.many? %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/configs/production_config/static.html.erb b/app/views/admin/communication/websites/configs/production_config/static.html.erb index 30b86e4b2..b826bccd0 100644 --- a/app/views/admin/communication/websites/configs/production_config/static.html.erb +++ b/app/views/admin/communication/websites/configs/production_config/static.html.erb @@ -3,10 +3,7 @@ baseURL: <%= @website.url %> ## LANGUAGE -<%# TODO I18n: Add "Default language" in Communication::Website %> -<% if @website.languages.many? %> -defaultContentLanguage: fr -<% else %> -defaultContentLanguage: <%= @website.languages.first.iso_code %> +<% if @website.languages.any? %> +defaultContentLanguage: <%= @website.default_language.iso_code %> <% end %> defaultContentLanguageInSubdir: <%= @website.languages.many? %> -- GitLab