Agile Web Development with Rails 7: "Cart empty" not using locale (page 234)

@rubys

In : rails7/depot_t/app/views/carts/_cart.html.erb

The button to empty cart is not using the locale and switches back to default “en”.

Change to:

 <div class="flex mt-1">
    <%= button_to t('.empty'), cart_path(cart,locale: I18n.locale), method: :delete,
                  class: 'ml-4 rounded-lg py-1 px-2 text-white bg-green-600' %>
    <%= button_to t('.checkout'), new_order_path(locale: I18n.locale),
                  method: :get,
                  class: 'ml-4 rounded-lg py-1 px-2 text-black bg-green-200' %>
  </div>

Thank you!

An alternate approach in this suggestion: Agile Web Development with Rails 7: Suggestion to simplify Chapter 15 Task J: Internationalization

1 Like