From aa84dd8ef5b16774a2f5f1a03dfaab37ec66ce9e Mon Sep 17 00:00:00 2001 From: Vincent Rolea <3525369+virolea@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:49:21 +0200 Subject: [PATCH] Change locale translation route to better reflect the domain --- ...nslation_keys_controller.rb => translations_controller.rb} | 2 +- app/controllers/rosetta/translations_controller.rb | 2 +- app/views/rosetta/locales/_locale.html.erb | 2 +- .../_translation_key.html.erb | 0 .../locales/{translation_keys => translations}/index.html.erb | 2 +- app/views/rosetta/translations/edit.html.erb | 2 +- config/routes.rb | 2 +- ...eys_controller_test.rb => translations_controller_test.rb} | 4 ++-- test/controllers/rosetta/translations_controller_test.rb | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-) rename app/controllers/rosetta/locales/{translation_keys_controller.rb => translations_controller.rb} (87%) rename app/views/rosetta/locales/{translation_keys => translations}/_translation_key.html.erb (100%) rename app/views/rosetta/locales/{translation_keys => translations}/index.html.erb (97%) rename test/controllers/rosetta/locales/{translation_keys_controller_test.rb => translations_controller_test.rb} (69%) diff --git a/app/controllers/rosetta/locales/translation_keys_controller.rb b/app/controllers/rosetta/locales/translations_controller.rb similarity index 87% rename from app/controllers/rosetta/locales/translation_keys_controller.rb rename to app/controllers/rosetta/locales/translations_controller.rb index a590a5a..f085615 100644 --- a/app/controllers/rosetta/locales/translation_keys_controller.rb +++ b/app/controllers/rosetta/locales/translations_controller.rb @@ -1,5 +1,5 @@ module Rosetta - class Locales::TranslationKeysController < ApplicationController + class Locales::TranslationsController < ApplicationController before_action :set_locale def index diff --git a/app/controllers/rosetta/translations_controller.rb b/app/controllers/rosetta/translations_controller.rb index 0725cff..60b44b6 100644 --- a/app/controllers/rosetta/translations_controller.rb +++ b/app/controllers/rosetta/translations_controller.rb @@ -9,7 +9,7 @@ def edit def update if @translation.update(translation_params) - redirect_to locale_translation_keys_path(@locale) + redirect_to locale_translations_path(@locale) end end diff --git a/app/views/rosetta/locales/_locale.html.erb b/app/views/rosetta/locales/_locale.html.erb index 2447554..f02c879 100644 --- a/app/views/rosetta/locales/_locale.html.erb +++ b/app/views/rosetta/locales/_locale.html.erb @@ -13,7 +13,7 @@ <% end %> <% unless locale.default_locale? %> - <%= link_to "Manage", locale_translation_keys_path(locale), class: "text-indigo-600 hover:text-indigo-900" %> + <%= link_to "Manage", locale_translations_path(locale), class: "text-indigo-600 hover:text-indigo-900" %> <% end %> diff --git a/app/views/rosetta/locales/translation_keys/_translation_key.html.erb b/app/views/rosetta/locales/translations/_translation_key.html.erb similarity index 100% rename from app/views/rosetta/locales/translation_keys/_translation_key.html.erb rename to app/views/rosetta/locales/translations/_translation_key.html.erb diff --git a/app/views/rosetta/locales/translation_keys/index.html.erb b/app/views/rosetta/locales/translations/index.html.erb similarity index 97% rename from app/views/rosetta/locales/translation_keys/index.html.erb rename to app/views/rosetta/locales/translations/index.html.erb index 198dac0..ccdf601 100644 --- a/app/views/rosetta/locales/translation_keys/index.html.erb +++ b/app/views/rosetta/locales/translations/index.html.erb @@ -35,7 +35,7 @@ - <%= render collection: @translation_keys, partial: "rosetta/locales/translation_keys/translation_key" %> + <%= render collection: @translation_keys, partial: "rosetta/locales/translations/translation_key" %> diff --git a/app/views/rosetta/translations/edit.html.erb b/app/views/rosetta/translations/edit.html.erb index 21022b4..3a6e654 100644 --- a/app/views/rosetta/translations/edit.html.erb +++ b/app/views/rosetta/translations/edit.html.erb @@ -14,7 +14,7 @@
- <%= link_to "Discard", locale_translation_keys_path(@locale), class: "btn btn-secondary" %> + <%= link_to "Discard", locale_translations_path(@locale), class: "btn btn-secondary" %> <%= f.submit "Save", class: "inline btn btn-primary" %>
<% end %> diff --git a/config/routes.rb b/config/routes.rb index 4604eb9..a158fc1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,7 @@ resources :locales do scope module: :locales do - resources :translation_keys, only: :index + resources :translations, only: :index end end diff --git a/test/controllers/rosetta/locales/translation_keys_controller_test.rb b/test/controllers/rosetta/locales/translations_controller_test.rb similarity index 69% rename from test/controllers/rosetta/locales/translation_keys_controller_test.rb rename to test/controllers/rosetta/locales/translations_controller_test.rb index f683bad..c4634e9 100644 --- a/test/controllers/rosetta/locales/translation_keys_controller_test.rb +++ b/test/controllers/rosetta/locales/translations_controller_test.rb @@ -1,13 +1,13 @@ require "test_helper" module Rosetta - class Locales::TranslationKeysControllerTest < ActionDispatch::IntegrationTest + class Locales::TranslationsControllerTest < ActionDispatch::IntegrationTest include Engine.routes.url_helpers test "index" do locale = Locale.create(code: "fr", name: "French") key = TranslationKey.create(value: "hello") - get locale_translation_keys_path(locale) + get locale_translations_path(locale) assert_response :success assert_includes response.body, "hello" end diff --git a/test/controllers/rosetta/translations_controller_test.rb b/test/controllers/rosetta/translations_controller_test.rb index 6b55869..5c3a726 100644 --- a/test/controllers/rosetta/translations_controller_test.rb +++ b/test/controllers/rosetta/translations_controller_test.rb @@ -21,7 +21,7 @@ class TranslationsControllerTest < ActionDispatch::IntegrationTest assert_equal "Bonjour", Translation.last.value assert_response :redirect - assert_redirected_to locale_translation_keys_path(@locale) + assert_redirected_to locale_translations_path(@locale) end test "update an existing translation" do @@ -33,7 +33,7 @@ class TranslationsControllerTest < ActionDispatch::IntegrationTest assert_equal "Bonjour", Translation.last.value assert_response :redirect - assert_redirected_to locale_translation_keys_path(@locale) + assert_redirected_to locale_translations_path(@locale) end end end