BartOtten
Library for localized/multilingual routes in Phoenix
This lib is now published and has a new topic.
Once this topic was about PhxAltRoutes. A lib pioneering localized routes for Phoenix.
It’s experimental work sparked and influenced second generation routing libs such as Cldr-Routes and Phoenix Localized Routes.
Phoenix Localized Routes is superseded by the third (and currently latest) generation: Routex - Extension driven superpowers for Phoenix Routes
Most Liked
BartOtten
Update
- The public API is becoming stable
- Localized Routes on Phoenix 0.16 was easier than on Phoenix 0.17. Ah well, got lot’s of goodies in return.
- Lots of refactoring still to do
THE BRAVE MAY START TO USE IT IN AN HOBBY PROJECT
Changelog
- Add example how to list all alternative routes on a page: http://localhost:4000/products
# the original route is wrapped in `PhxLocalizedRoutes.Helpers.loc_route` which receives a scope config (opts).
<%= for {slug, opts} <- ExampleWeb.LocalizedRoutes.local_scopes!(flat: true) do %>
<span>
<%= live_redirect " [#{slug}] ", to: PhxLocalizedRoutes.Helpers.loc_route(Routes.product_index_path(@socket, :index), opts) %>
</span>
<% end %>
malloryerik
Get well soon!
BartOtten
CLDR had it’s release of CLDR Route which was inspired by this lib-in-progress. There is overlap in purpose, yet enough difference in features to continue this lib. Will make a comparison table some day to help users making the choice what fits best for their purpose.
Due to the better documentation and function naming skills of @kip, I have merged back some improvements. So thanks Kip for part of this update!
- alias original helper module as OriginalRoutes
- improved docs
- improved function naming
- :assigns => :assign (to keep :assign_new as option for the future)
- development: more debug logging
- development: better stacktrace
- much more
Todo:
- assign inheritance
- getting rid of the Assigns struct
- e2e tests in addition to current low level tests
Later:
- loc_link which also translates the links(??)
- option to not render a parent route
csadewa
Hi @BartOtten , here’s some feedback since you are looking for one:
- Is this library is a drop-in replacement to Phoenix Routes? Routing — Phoenix v1.6.6 in which case aspect such as security (like token decoding, cross browser validation, etc.)
- What is the intended usage of the library? Why would people consider using AltRoutes rather than the standard Phoenix Routes? it’s not clear to me, right now it seems AltRoutes looks like a smaller codegen of standard Phoenix Route.
sfusato
1 - I see PhxMultiLangRoutes as more descriptive of what the library does. PhxLocalizedRoutes could also be an idea.
2 - Would :short differ from :slug in many cases? If not, having one key less could be desirable. Even in europe/eu case, if the slug is europe, I would find it much more intuitively that the helper uses it as well (europe_product_index_path).
4 - A far alley, maybe even out of the scope of the library, could be the support of different domains/subdomains:
"en" => "example.com",
"nl" => "nl.example.com",
"be" => "be.example.com",







