replace "/" with "-" before route parameter?
setoelkahfi opened this issue ยท 7 comments
Really cool gem, thanks so much ๐
Is it possible to replace the "/" with "-" before the route paratmeter?
I want to produce these kind or urls:
domain.com/product-detail-343
domain.id/detail-produk-343
I tried this in routes.rb
get 'product_detail:slug', to: 'product#detail', as: :product_detail
and in each locales yml file:
product_detail: product-detail-
and it doesn't work. It works however, if i puth / before the :slug
same issue.
how to translate this:
get 'test-user-:id', to: "test#show"
Sorry for this very late reply.
Ultimately, I'm not working on Rails and I'm just keeping this gem up-to-date in my free time. Time is a limited resource, I need space for my personal life and well, stuff like that.
Please try this one:
routes.rb
localized do
resources :products
get :product_detail, to: 'products#show'
end
en.yml
en:
hello: "Hello world"
routes:
product_detail: 'product-detail-:id'
Helper: product_detail_path(product)
Let's say, for product 3, url: /product-detail-3
(please fix according to your use case, I see you are using slug
)
I've tested this with RoR 5.2.3 and route_translator 5.10.0 and it works.
Let me know
Thank you @tagliala for your reply. It works for me.
I am using I18n for locales. so in the case of de
there is prefix added de when translated route generated. can I remove this prefix during the route translation?
I am using I18n for locales. so in the case of de there is prefix added de when translated route generated. can I remove this prefix during the route translation?
Could you please clarify this?
cars_es GET /es/coches(.:format) cars#index {:locale=>"es"}
in this case, can I remove the prefix es
?
I found the solution.
config. hide_locale = true
Thanks for your help @tagliala ๐
I think I've answered this question here: #190 (comment) so I will close this thread