Globalizing Mephisto (Part 4)

Welcome to the fourth part of the Globalizing Mephisto article series which shows you how to enable the definition of the active locale via a path parameter rather than via subdomains.

When I first posted about the mephisto_i18n plugin on the mephisto forum some people mentioned that they thought using subdomains to define the active locale wasn’t very handy, especially for mephisto instances on shared hosts.

In response to that feedback, I’ve now updated the plugin to allow locale definition either via:

  • subdomains (default)
  • path parameter

Using the ‘path parameter’ mode means you can have urls like this:

1
2
3
4
5
http://webtypes.com/
http://webtypes.com/es
http://webtypes.com/es/2007/5/15/globalizando-mephisto-3-parte
http://webtypes.com/es/sobre
http://webtypes.com/es/admin/articles/edit/2

Enabling path parameter mode in 3 easy steps

Update environment.rb

Add the following line to your environment file:

Mephisto::I18N.locale_definition = :path

Update routes.rb

Replace the call to:

Mephisto::Routing.connect_with map
with

Mephisto::I18N::Routing.connect_with map
in your routes file.

Update your liquid templates (optional)

Optionally, modify any hard-coded links in your liquid templates like so:

before

<a href="/{{'blog' | t: 'urls'}}">{{'Weblog' | t}}</a>
after

<a href="{{i18n.l}}/{{'blog' | t: 'urls'}}">{{'Weblog' | t}}</a>

NOTE: This assumes you’ve already installed the plugin for a single site or multi site globalized mephisto.

What has been done for you automatically…

When in path parameter mode and the active locale is not the base locale then:

  • The plugin automatically rewrites urls generated via the url_rewriter which means that all links using link_to and family are automatically correctly localized.
  • The article/section & site urls (tag/search) are automatically prepended with the correct language code which means most of the links of your site will just work.

Please do try out this mode and, as usual, I appreciate your feedback.

Saimon Moore (also in Greek, Spanish & Catalan :)

7 comments on “Globalizing Mephisto (Part 4)”

  1. Lukasz Nowak

    Hi, I’d like to know is it polish version of mephisto? If not could we translate mephisto?

  2. Kinderspiele

    Great articles! Thanks a lot.

  3. izmir web tasarım

    Thanks for this useful article

  4. ht
  5. sepetli platform

    Thanks for this article and most generaly for this very amazing website :) this information most important for me.

  6. kevin

    Hamburg VS Windows 7 , which is cheaper ? Wholesale cheap Microsoft Windows 7 office 2010 office 2007 product key I just in my IBM X200 laptop above installed WINDOWS 7 ULTIMATE X86 . But only 30 day trial. I would like to activate, lift the 30-day trial limit! finally I made my purchase on page Wholesale Microsoft Windows 7 product key payment by paypal and as 4 hours to leave I was sent to my mail, perform the installation in clean and fully active, even I got to the Windows Genuine Advantage pag and step no tan, everything works perfect. My only cost Wholesale cheap microsoft WINDOWS 7 ULTIMATE Product KEY for $ 13.99. Wholesale cheap microsoft Office 2010 professional plus product key for $39.99 Wholesale cheap Microsoft office 2007 product key He’s selling price almost KFC Hamburg. I think he is very cost-effective, and no risk. Because he is so cheap! Wholesale cheap microsoft WINDOWS 7 ULTIMATE key Wholesale cheap microsoft windows 7 professional key

  7. Tagesgeld

    Thanks thats helps me a lot.

    Tagesgeld

Leave your comment