Consider this example. I have a product model that has discount_percentage. And we support multiple locales. In the view, we do not want the i18n material to ruin the view. Therefore, we help to read better and, possibly, reuse it in other views: render_product_discount(code see below), which will show the discount status of this product. And we use the i18n lazy search function throughout the application. But when we want to check this helper method, we get an error:
# RuntimeError:
# Cannot use t(".product_discount") shortcut because path is not available
because for the translator does not exist pathto extend the lazy translation key.
Expected Result: This product has a 20% discount.
Assistant Name: render_product_discount
def render_product_discount
t('.product_discount', discount_percentage: product.discount_percentage)
end
es:
products:
show:
product_discount: Este producto tiene un %{discount_percentage} descuento.
en:
products:
show:
product_discount: This product has %{discount_percentage} discount.
How to do it? Thanks in advance.