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

Qqwy
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New
Eiji
ExApi is a library that I’m developing now and hope release soon This library will allow to: list all apis list all api implementation...
New
dbern
I’m excited to announce that TaxJar has developed and open-sourced DateTimeParser. We developed it because we found a need to parse user ...
New
mathieuprog
Hello :wave: Allow me to introduce you to Tz, an alternative time zone database support to Tzdata. Why another library? First and fore...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
tmbb
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 18262 141
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
maltoe
Hello! Came here to announce ChromicPDF, a pet project PDF generator I’ve been working on for the past few months. Why another PDF gener...
New

Other popular topics Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Sub Categories:

We're in Beta

About us Mission Statement