BartOtten

BartOtten

Phoenix Localized Routes - Localized/multilingual routes in Phoenix

Phoenix Localized Routes is dead. Long live Routex!

Phoenix Localized Routes did pave the way for some routing libs but that was possibly it’s only award. As it was the first of it’s kind the design very much left much to be desired. It’s successor, Routex, is in every aspect a better lib.

  • better design
  • better code
  • better documentation
  • better performance

What was Phoenix Localized Routes?

Localize your Phoenix website with multilingual URLs and custom template assigns; enhancing user engagement and content relevance.

                    ⇒ /products/:id/edit                  @loc.locale = "en_US"
/products/:id/edit  ⇒ /nederland/producten/:id/bewerken   @loc.locale = "nl_NL"
                    ⇒ /espana/producto/:id/editar         @loc.locale = "es_ES"

Top Features and Benefits

Simple when possible, powerful where needed.

Usage Summary

  • Add a configuration file describing which alternate routes to generate.
  • Replace less than 10 lines of code in your existing Phoenix application.
  • Optionally:
    • Run mix gettext.extract --merge
    • Translate the URL parts like any other translatable text.
  • Run mix phx.routes to verify the result.

You can now visit the localized URLs. Links and redirects in your application will automatically keep the visitors in their current (localized) scope.

Example App

Documentation

HexDocs (stable) and GitHub Pages (development).

Requirements and Installation

See the Usage Guide for the requirements and installation instructions.

Additional Resources

How it Works: High-level overview of Phoenix Localized Routes’ main features.
Usage guide: usage.html | hexdocs
Example app: Example repo | Github and Live at | Fly.io

Source: phoenix_localized_routes | GitHub
Package: phoenix_localized_routes | hex

Most Liked

kip

kip

ex_cldr Core Team

Sure have! @BartOtten is doing an awesome job.

BartOtten

BartOtten

I would not dare to publish a localization lib without @kip’s blessing :wink: Therefor I asked him personally to have a look at the lib when it was pre-0.1.0. Dare to say we both share a vision.

As a result CLDR Routes and Phoenix Localized Routes have influenced each other for the better. Both coming from another direction and with other features, but both targeting improvement in localization of Phoenix apps.

Soon will pick up the conversation and check which area would add the greatest improvement to accomplish that shared vision.

kip

kip

ex_cldr Core Team

I’ll be publishing my first livebook on this topic in the next week or so based upon my ElixirConf EU talk, and I have a few more in planning to follow that. I’ll post an announcement in the ex_cldr thread soon.

BartOtten

BartOtten

Progress on Phoenix 1.7 Verified Routes
Next week a new version will be released with support for verified routes!

It will feature a new config option to specify the sigil to use, allowing the developer to pick one not confliction with possible other used sigils.

Although Phoenix Route Helpers will still be supported, they are now fully optional.

afbeelding

BartOtten

BartOtten

0.1.3-rc.1

This version got released to Hex.pm and can be tested by adding/changing the dep in mix.exs:

      {:phoenix_localized_routes, "~> 0.1.3-rc.1"}

Call for testers

Please help me test this release by

  • upgrading your existing installation. There should be no breaking changes.
  • using this lib with Phoenix 1.7 (view Usage Guide @ Github)

Issues can be reported here


Changelog

Support Phoenix Verified Routes

Phoenix 1.7 includes a new Phoenix.VerifiedRoutes feature which provides ~p for route generation with compile-time verification.

This release adds support for Localized Verified Routes using sigil ~l. The sigil can be customized by setting the sigil_localized option in the configuration.

Overriding sigil ~p

The default sigil ~p used by Phoenix.VerifiedRoutes can be overridden by setting sigil_localized: "~p". When doing so, the original sigil is by default renamed to ~o. This can be customized by setting the sigil_original option.

Example

For an example of how to implement Phoenix Localized Routes using the new Verified Routes, have a look at the commits of the example app (branch bo/1.7).

Other changes

  • Use Phoenix.Component.assign for Phoenix >= 1.7

Showcase

The Example App is now live @ fly.io

Where Next?

Popular in Libraries Top

marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
devonestes
Introducing assertions, the library that helps you write really great test assertions! GitHub: https://github.com/devonestes/assertions ...
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
OvermindDL1
Been making an MLElixir thing (not released yet…) for fun in spare time in the past day. I’m just trying to see how much I can get an ML...
132 13487 106
New
danschultzer
In short Plug n’ play OAuth 2.0 provider library. Just set up a resource owner schema with Ecto (your user schema), install the dependen...
New
tfwright
After working on it for a couple of months and using it in production for most of that time, today I’ve released LiveAdmin, a LiveView ba...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
gjaldon
As the title states, EctoEnum has just been updated after some time of hardly any activity in the repo. Here’s the latest release: https:...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Sub Categories:

We're in Beta

About us Mission Statement