Skip to content

Cldr Routes version 0.3.0

Compare
Choose a tag to compare
@kipcole9 kipcole9 released this 17 Jul 14:05
· 72 commits to main since this release

Enhancements

  • Add support for live routes. Thanks to @ringofhealth for the report. Closes #1.

  • Support interpolating locale, language and territory into a route. Thanks to @rubas for the suggestion. Closes #3. For example:

  localize do
    get "/#{locale}/locale/pages/:page", PageController, :show, as: "with_locale"
    get "/#{language}/language/pages/:page", PageController, :show, as: "with_language"
    get "/#{territory}/territory/pages/:page", PageController, :show, as: "with_territory"
  end
  • Uses the macros from Gettext rather than the functions when generating routes. This means that the mix tasks gettext.extract and gettext.merge now work as expected. Closes #3.

  • Rewrite the LocalizedHelpers module that now proxies into the standard Phoenix Helpers module rather than maintaining a separate forked module. As a result:

    • The standard Helpers module now generates helper names that have locale suffixes. That is user_path becomes user_en_path, user_fr_path and so on.
    • The LocalizedHelpers module hosts the standard helper names (like user_path) which will then call the appropriate standard helper depending on the result of Cldr.get_locale/1.
  • Add functions to output the localised routes. At compile time a module called MyApp.Router.LocalizedRoutes is created. This module hosts a __routes__/0 function which can be passed as an argument to the Phoenix standard Phoenix.Router.ConsoleFormatter.format/1 function that returns a string representation of configured localized routes. These can then be IO.puts/1 as required. In the next release a mix task will automate this process.

Thanks to @rubas and @ringofhealth for their extreme patience while I worked this through. Closes #1, and #4.