Skip to content

Commit

Permalink
Change locale translation route to better reflect the domain
Browse files Browse the repository at this point in the history
  • Loading branch information
virolea committed Sep 12, 2024
1 parent 47030ac commit aa84dd8
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Rosetta
class Locales::TranslationKeysController < ApplicationController
class Locales::TranslationsController < ApplicationController
before_action :set_locale

def index
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/rosetta/translations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/views/rosetta/locales/_locale.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
</td>
</tr>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</thead>

<tbody class="divide-y divide-gray-200 bg-white">
<%= render collection: @translation_keys, partial: "rosetta/locales/translation_keys/translation_key" %>
<%= render collection: @translation_keys, partial: "rosetta/locales/translations/translation_key" %>
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/rosetta/translations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>

<div class="absolute inset-x-0 bottom-0 flex justify-end gap-2 py-2 pl-3 pr-2">
<%= 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" %>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

resources :locales do
scope module: :locales do
resources :translation_keys, only: :index
resources :translations, only: :index
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/rosetta/translations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit aa84dd8

Please sign in to comment.