Translated routes
Closed this issue · 3 comments
jakub-zawislak commented
I wanted to create translated routes, like here:
https://github.com/BeSimple/BeSimpleI18nRoutingBundle#yaml-routing-file
I have modified Polygot module
defmacro localize({verb, meta, [ path, plug, plug_opts | rest ]} = route) when verb in @http_methods do
Enum.map(@locales, fn({locale, info}) ->
path = if Enum.count(rest) > 0 do
translated_path = Enum.at(rest, 0)[:translations][String.to_atom(locale)]
if translated_path do
"/"<>translated_path
else
path
end
else
path
end
{ verb, meta, ["/#{info.path_prefix}#{path}", plug, [ action: plug_opts, locale: locale ], rest ]}
end)
end
and router:
localize get "/how-it-works", HowItWorksController, :index, translations: [
pl: "jak-to-dziala"
]
Same as in #2 I don't know if it's good solution, so I'm not creating a pull request
boudra commented
Hey @Harry27PL,
I think that both ideas you posted are amazing, I don't have access to a computer these days so I'll look at them further and put them into master when I have some time!
thanks a lot :)
boudra commented
and I think that is actually a much better solution than using Gettext