Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
i18n routes (multilanguage segment names)
  • Is there a way to add support for multilanguage segment names inside routes? example:
    English: /news/1231/a-news-article
    Dutch: /nieuws/1231/een-nieuws-artikel (i do not want a nl or a en (language segment inside url, but it is based on the domain extention (http://www.english.com = english, http://www.example.nl = dutch). Thanks :)
  • You can simply create two URI's with one location...
    array = (
    
      '/news/1231/a-news-article' = '...',
      '/nieuws/1231/een-nieuws-artikel' = '...'
    
    );
    

    If it isn't what you need then sorry... try to help as I can. )
  • I want to use words as nieuws (for news) from a language file ;)
  • Technically, routes.php is just a plain PHP file. So you should be able to do
    // routes.php
    
    // get the localized name for 'news'
    $news = __('news');                      // __() is an alias for \Lang::line()
    
    return array(
        "$news/:id/:title" => 'news/item'
    );
    
    ( disclaimer: haven't tested this at all... )
  • Is the translation function already ready by importing the config? I hope so :)
  • Just tested it with a stock install of Fuel, by adding
    \Lang::load('test');
    var_dump(__('hello'));
    
    to app/config/routes.php. Works without problems.
  • Ah, i just tested it, thanks.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion