Open olivermt opened 2 years ago
Sorry for the late reply, did not get a notification. I will get to this soon, as RC1 has just been released today so the verified routes implementation is considered ‘done’.
Released a Release Candidate version you can try: https://elixirforum.com/t/phoenix-localized-routes-localized-multilingual-routes-in-phoenix/48486/22?u=bartotten
Please let me know if it works as expected.
Tremendous! Will try this next week
Hi @olivermt,
Could you provide me a status report?
I've encountered an issue when trying to use query params:
<.link href={~p"/users/register?#{[foo: "bar"]}"}>Register</.link>
<.link href={~p"/users/register?#{%{foo: "bar"}}"}>Register</.link>
On the locale to which these routes belong, in this case the en
locale, there are only compilation warnings: no route path matches
that aren't there when switching to the ~o
sigil (Phoenix's verified routes sigil basically).
When you're switching to a different locale, there's an error thrown:
<.link href={~p"/users/register?#{[foo: "bar"]}"}>Register</.link>
Protocol.UndefinedError at GET /europe/be/producten
protocol Phoenix.Param not implemented for [foo: "bar"] of type List. This protocol is implemented for the following type(s): Any, Atom, BitString, Float, Integer, Map
<.link href={~p"/users/register?#{%{foo: "bar"}}"}>Register</.link>
ArgumentError at GET /europe/be/producten
maps cannot be converted to_param. A struct was expected, got: %{foo: "bar"}
Hard coding the params works:
<.link href={~p"/users/register?foo=bar"}>Register</.link>
but only on the hard coded locale route. It's not being copied to the other localized routes:
http://localhost:4000/users/register?foo=bar
http://localhost:4000/europe/be/gebruikers/registreren
http://localhost:4000/europe/nl/gebruikers/registreren
http://localhost:4000/gb/users/register
Expected:
http://localhost:4000/users/register?foo=bar
http://localhost:4000/europe/be/gebruikers/registreren?foo=bar
http://localhost:4000/europe/nl/gebruikers/registreren?foo=bar
http://localhost:4000/gb/users/register?foo=bar
Tested on the bo/phx1.7
branch of the example application.
Hi @sfusato and @olivermt,
The refactoring of Phoenix Localized Routes has lead to a more flexible lib: Routex
. Please give it a try as I am eager to get some feedback before I "publish" the lib at Elixir forum.
Migration from Phoenix Localized Routes (PLR) to Routex Although I have not written a migration guide yet, it should be straightforward.
Links Hex: https://hex.pm/packages/routex Demo: https://routex.fly.dev/ Full diff adding Routex to the demo app: https://github.com/BartOtten/routex_example/commit/a1ca0d0f1fb411d33a15864cc765dbb39de428da
@BartOtten Can you make the routex_example
repository public?
My bad :)
Hello,
Have you seen Chris' presentation on phoenix 1.7 and verified routes? Do you reckon this lib will be able to work seamlessly with that? Have you given it any thought?