phoenix_localized_routes
                                
                                
                                
                                    phoenix_localized_routes copied to clipboard
                            
                            
                            
                        Thoughts on this working with ~p routes
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?
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
enlocale, there are only compilation warnings:no route path matchesthat aren't there when switching to the~osigil (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.
- A few key names changes and a list of extensions should be added. https://github.com/BartOtten/routex_example/blob/main/lib/example_web/routex_backend.ex
 - The webserver entrypoint should be slightly adapted https://hexdocs.pm/routex/usage.html
 
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 :)