From 84b51acc5e508fdd0d21419e8d2fb58e295d9b6b Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Wed, 14 Aug 2024 11:47:57 -0500 Subject: [PATCH] Provide aria-label for main navigation --- Gemfile | 2 ++ app/components/blacklight/top_navbar_component.html.erb | 4 ++-- app/components/blacklight/top_navbar_component.rb | 4 ++++ config/locales/blacklight.ar.yml | 3 +++ config/locales/blacklight.de.yml | 3 +++ config/locales/blacklight.en.yml | 4 ++++ config/locales/blacklight.es.yml | 3 +++ config/locales/blacklight.fr.yml | 3 +++ config/locales/blacklight.hu.yml | 3 +++ config/locales/blacklight.it.yml | 3 +++ config/locales/blacklight.nl.yml | 3 +++ config/locales/blacklight.pt-BR.yml | 3 +++ config/locales/blacklight.sq.yml | 3 +++ config/locales/blacklight.zh.yml | 3 +++ spec/test_app_templates/lib/generators/test_app_generator.rb | 2 +- 15 files changed, 43 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 8c2dc0a7e..967e4fc25 100644 --- a/Gemfile +++ b/Gemfile @@ -35,3 +35,5 @@ end # END ENGINE_CART BLOCK eval_gemfile File.expand_path("spec/test_app_templates/Gemfile.extra", File.dirname(__FILE__)) + +gem "easy_translate", "~> 0.5.1" diff --git a/app/components/blacklight/top_navbar_component.html.erb b/app/components/blacklight/top_navbar_component.html.erb index d9636f9e7..44958adde 100644 --- a/app/components/blacklight/top_navbar_component.html.erb +++ b/app/components/blacklight/top_navbar_component.html.erb @@ -1,4 +1,4 @@ - diff --git a/app/components/blacklight/top_navbar_component.rb b/app/components/blacklight/top_navbar_component.rb index 5c8b9611e..bb9448576 100644 --- a/app/components/blacklight/top_navbar_component.rb +++ b/app/components/blacklight/top_navbar_component.rb @@ -10,6 +10,10 @@ def initialize(blacklight_config:) delegate :application_name, :container_classes, to: :helpers + def aria_label + t('blacklight.top_navbar.aria.container_label') + end + def logo_link(title: application_name) link_to title, blacklight_config.logo_link, class: 'mb-0 navbar-brand navbar-logo' end diff --git a/config/locales/blacklight.ar.yml b/config/locales/blacklight.ar.yml index 1957a60af..e5ebc6076 100644 --- a/config/locales/blacklight.ar.yml +++ b/config/locales/blacklight.ar.yml @@ -215,6 +215,9 @@ ar: email: بريد إلكتروني sms: إرسله كرسالة نصية قصيرة title: أدوات + top_navbar: + aria: + container_label: التنقل الرئيسي welcome: مرحبًا! views: pagination: diff --git a/config/locales/blacklight.de.yml b/config/locales/blacklight.de.yml index 4f4c3b667..3838f1101 100644 --- a/config/locales/blacklight.de.yml +++ b/config/locales/blacklight.de.yml @@ -202,6 +202,9 @@ de: email: E-Mail sms: SMS title: Werkzeuge + top_navbar: + aria: + container_label: Hauptnavigation welcome: Willkommen! views: pagination: diff --git a/config/locales/blacklight.en.yml b/config/locales/blacklight.en.yml index 8120f337e..339f86ab1 100644 --- a/config/locales/blacklight.en.yml +++ b/config/locales/blacklight.en.yml @@ -234,6 +234,10 @@ en: did_you_mean: 'Did you mean to type: %{options}?' + top_navbar: + aria: + container_label: Main navigation + main: aria: main_container: 'Main content' diff --git a/config/locales/blacklight.es.yml b/config/locales/blacklight.es.yml index 6af3e01a4..604d8cce9 100644 --- a/config/locales/blacklight.es.yml +++ b/config/locales/blacklight.es.yml @@ -201,6 +201,9 @@ es: email: Correo electrónico sms: Enviar SMS title: Herramientas + top_navbar: + aria: + container_label: Navegación principal welcome: "¡Bienvenido!" views: pagination: diff --git a/config/locales/blacklight.fr.yml b/config/locales/blacklight.fr.yml index 8627c3ba8..30c60603b 100755 --- a/config/locales/blacklight.fr.yml +++ b/config/locales/blacklight.fr.yml @@ -201,6 +201,9 @@ fr: email: Envoyer sms: SMS title: Outils + top_navbar: + aria: + container_label: Navigation principale welcome: Welcome! views: pagination: diff --git a/config/locales/blacklight.hu.yml b/config/locales/blacklight.hu.yml index d570cf698..dadba8cfd 100644 --- a/config/locales/blacklight.hu.yml +++ b/config/locales/blacklight.hu.yml @@ -199,6 +199,9 @@ hu: email: Email sms: Küldés SMS-ben title: Eszközök + top_navbar: + aria: + container_label: Fő navigáció welcome: Üdvözöljük! views: pagination: diff --git a/config/locales/blacklight.it.yml b/config/locales/blacklight.it.yml index 57e418f32..e71637b08 100644 --- a/config/locales/blacklight.it.yml +++ b/config/locales/blacklight.it.yml @@ -202,6 +202,9 @@ it: email: Invia per e-mail sms: Invia per SMS title: Strumenti + top_navbar: + aria: + container_label: Navigazione principale welcome: Benvenuti! views: pagination: diff --git a/config/locales/blacklight.nl.yml b/config/locales/blacklight.nl.yml index 1c2cdcfac..8e8d829b7 100644 --- a/config/locales/blacklight.nl.yml +++ b/config/locales/blacklight.nl.yml @@ -199,6 +199,9 @@ nl: email: Email sms: SMS dit title: Hulpmiddelen + top_navbar: + aria: + container_label: Hoofdnavigatie welcome: Welkom! views: pagination: diff --git a/config/locales/blacklight.pt-BR.yml b/config/locales/blacklight.pt-BR.yml index c5a2b079c..aea5b6a6c 100644 --- a/config/locales/blacklight.pt-BR.yml +++ b/config/locales/blacklight.pt-BR.yml @@ -200,6 +200,9 @@ pt-BR: email: Email sms: SMS title: Ferramentas + top_navbar: + aria: + container_label: Navegação principal welcome: Bem-Vindo! views: pagination: diff --git a/config/locales/blacklight.sq.yml b/config/locales/blacklight.sq.yml index 0d112b852..9ced9ef28 100644 --- a/config/locales/blacklight.sq.yml +++ b/config/locales/blacklight.sq.yml @@ -199,6 +199,9 @@ sq: email: Email sms: Dërgo SMS title: Veglat + top_navbar: + aria: + container_label: Lundrimi kryesor welcome: Mirësevini! views: pagination: diff --git a/config/locales/blacklight.zh.yml b/config/locales/blacklight.zh.yml index b225c6a23..327a4c936 100644 --- a/config/locales/blacklight.zh.yml +++ b/config/locales/blacklight.zh.yml @@ -199,6 +199,9 @@ zh: email: 电子邮件 sms: 发送短信 title: 工具 + top_navbar: + aria: + container_label: 主导航 welcome: 欢迎! views: pagination: diff --git a/spec/test_app_templates/lib/generators/test_app_generator.rb b/spec/test_app_templates/lib/generators/test_app_generator.rb index c8e3fc439..9a9f6c69f 100644 --- a/spec/test_app_templates/lib/generators/test_app_generator.rb +++ b/spec/test_app_templates/lib/generators/test_app_generator.rb @@ -39,7 +39,7 @@ def add_component_template_override src_template = File.join(Blacklight::Engine.root, 'app', 'components', 'blacklight', 'top_navbar_component.html.erb') target_template = File.join('app', 'components', 'blacklight', 'top_navbar_component.html.erb') create_file(target_template) do - File.read(src_template).gsub('role="navigation"', 'role="navigation" data-template-override="top_navbar_component"') + File.read(src_template).gsub('aria-label', 'data-template-override="top_navbar_component" aria-label') end end end