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

nikolis
BeamScope Why I created this: Needed some very particular metrics regarding the state of my Elixir cluster in a relatively small project...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews