View Source Routex.Extension.Translations (Phoenix Routes Extension Framework v0.1.0-alpha.6)

Enables users to enter URLs using localized terms which can enhance user engagement and content relevance.

Extracts segments of a routes' path to a translations domain file (default: routes.po) for translation. At compile-time it combines the translated segments to transform routes.

configuration

Configuration

defmodule ExampleWeb.RoutexBackend do
use Routex,
extensions: [
+ Routex.Extension.Translations
]
+ translations_backend: MyApp.Gettext,
+ translations_domain: "routes.po",

pseudo-result

Pseudo result

# when translated to Spanish in the .po file
# - products: producto
# - edit: editar

/products/:id/edit   /producto/:id/editar

routex-attrs

Routex.Attrs

Requires

  • locale

Sets

  • none

use-case-s

Use case(s)

This extension can be combined with Routext.Extension.Alternatives to create multilingual routes.

Use Alternatives to create new scopes and provide a :locale per scope and Translations to translate the alternative routes.

                     /products/:id/edit                  locale = "en"
/products/:id/edit   /nederland/producten/:id/bewerken   locale = "nl"
                     /espana/producto/:id/editar         locale = "es"