Open nicolasblanco opened 2 months ago
It's a very reasonable request, but I'm actually not quite sure how to go about it. Let me explain:
ex_cldr
code base and libraries, the code I dislike the most is route helpers because that required some seriously horrible coding to grab parts of Phoenix route helpers and modify them. I'm a bit terrified to revisit them (ok, so perhaps thats not a good reason to avoid doing the work).The call to Cldr.get_locale/0
is just a call to Process.get/1
so thankfully that is not big overhead - but I agree that the ergonomics aren't great when you just want to generate a route for a specific locale. Let me think on this and revert after some more coffee.
Thanks for your fast answer.
I also agree that because Phoenix went to deprecate helpers, it's maybe not wise to integrate more right back...
Because the new way of generating routes is by using a sigil, what do you think of a special modifier of the sigil q
you implemented?
Basically the locale could be passed as a modifier to the sigil q
to force the generation of the path to a specific locale.
I'm not sure of what's allowed by the syntax but it could be something like:
~q"/users"fr
# or
~q"/users"/fr
# or even
~q"/users"/loc_fr
Thats a good suggestion. I'm hesitating just a little because there is a proposal to add HTTP verbs as flags to sigil_p
which might make this tricky. Nevertheless I'll work up an experiment to see what I can do for this. It might take until the weekend though.
Hello,
thank you for the library, I'm just discovering it and trying to see if I could integrate it in my project.
This is more a question than issue, but I'll be happy to provide a PR to improve the documentation. I've searched the doc and README and something is not clear to me : is it possible to force the generation of a path in a specific locale (if it was defined correctly) without the need to change the locale in the Cldr module ?
In the README there is this example:
It seems fine but what about generating paths in different locales directly in my HTML template, changing globally the locale in Cldr multiple times to render a single HTML seems too heavy.
Thanks!
Nicolas.