BartOtten

BartOtten

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

Showing Posts 1 to 10

csadewa

csadewa

Hi @BartOtten , here’s some feedback since you are looking for one:

  1. Is this library is a drop-in replacement to Phoenix Routes? Routing — Phoenix v1.8.8 in which case aspect such as security (like token decoding, cross browser validation, etc.)
  2. 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

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",
BartOtten

BartOtten OP

  1. Great suggestion, was already done (just not pushed yet)
  2. I chose to call it rename it to prefix, but not include it in the example config as it’s just an option for then needed.
  3. As the assigns are freeform (you define the struct yourself), one can just add key :domain. Or did you have something else in mind?
sfusato

sfusato

My idea was regarding sites that run each localized version on different subdomains entirely. So, the french version on fr.example.com, the english/default on example.com etc, thus the path helpers/router macros will need to generate the paths differently and I suppose it would also involve different endpoint/router for each locale. Again, a very var away alley :grin:

BartOtten

BartOtten OP

Major refactoring in progress; will soon push a revised edition.

BartOtten

BartOtten OP

Changelog (pushed so far, refactoring in progress)

- renamed lib
- restructured config
- less dynamic, more compiled; the config is extended with generated values during compilation time.
- use native :assigns for the scopes
- simplified Plug
- fixed compilation issues
- removed (dev) helper function clutter
- added assigned_values(key or list of keys)
BartOtten

BartOtten OP

I hope the linked README will now anwer those questions. If not, please let me know.

BartOtten

BartOtten OP

Afaik this can be done by pointing all subdomains to the same location (with all routes) and use a SetLocale plug (see README) to steer people to the correct localized route.

I have a conversation with @kip from ex_cldr to streamline/align libs and efforts.

BartOtten

BartOtten OP

Update

  • replace live_session with on_mount/1
  • add option to get flattened config with composite keys
  • use dedicated loc_scope_helper
  • add loc_scope_helper to assigns during config compilation

BROKE A FEW THINGS, so use commit 8d2c608208af06e2edd75a0c45f4022f967193e9 to a checkout a working example

Next stop: Add example how to list all alternative routes on a page.
I had this working but the syntax was evil. Will probably add a loc_link macro or patch the native Phoenix link, live_redirect, etc

BartOtten

BartOtten OP

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

# 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 %>

Where Next? Top

Trending in RFCs Top

manuel-rubio
There was some time when I started thinking about giving a boost to Lambdapad, the initiative from @garretsmith in Erlang that I loved wa...
New
Agostinho1965
Hey everyone — I’m putting together a practical, code-first book on building production-ready business applications with Phoenix LiveView...
New
andreasronge
You set up environments, each with its own tools, its own data and its own limits, and programs get evaluated in them. The same program r...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews