Phoenix Localized Routes - Localized/multilingual routes in Phoenix

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.


HexDocs (stable) and GitHub Pages (development).

We also provide an example application you can experiment with.

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

Source: phoenix_localized_routes | GitHub
Package: phoenix_localized_routes | hex


This looks promising, I’ll have to try it out in one of my Phoenix projects!


It would be nice some tutorial or video using this!

Great idea; will write a blog once I have some time (currently adding specs to the functions)

In the meantime the usage guide can be used. Added the link to the opening post.

1 Like

Yes, I saw the usage guide after posting here.
@BartOtten if you create this tutorial on the blog I would like to have some notification for this.
Thank you for your reply!

Looks great!

I wonder if @kip has already seen this! :blush:

Sure have! @BartOtten is doing an awesome job.


Hello, @kip I would like to know if you have a tutorial or video doing the internationalization of the app?
using the dependencies you have created!
I know one it is the cldr.

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.


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.


A small update has been published on Hex with a very limited change for end users. Therefor it became…


1. Enhancements

  • Fixed error reported by Dialyzer
  • Added typespecs
  • Modules split for better test experience

2. Breaking Change

  • Helpers.loc_route requires :loc_opts of type Scope.Flat.t() | nil instead of freeform map | nil

The README has been rewitten, hopefully better emphasizing the benefits and unique selling points of the library.

As I am not a native speaker nor the ultimate documentation writer, I wonder if someone could provide some tips for improvement.

Snip snip (a post ended up here instead of PM)

This is exactly what I need for my next project. Happy coincidence that you published it recently. @BartOtten Thanks :slight_smile:

1 Like