Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
i18n in Fuel
  • how do i do multilingual sites in Fuel? endresult should look like http://mci.vebia.ee/
    the example code is written in CI https://github.com/keevitaja/mci-codeigniter do i have to extend the core as well?
  • it seems, extending the lang.php does not help, cause it is not loaded like things are done in CI. i need to change the languages each time fuel loads. how do i do that? i belive on option is to write a sepparate class and call it in each controller, but it doesn't sound right. any thought on that?
  • thanx to freenode i came up with a solution: app/classes/controller.php
    <?php
    
    abstract class Controller extends Fuel\Core\Controller {
      function __construct(\Request $request) {
        parent::__construct($request);
        
        // do the i18n stuff here
      }
    }
    

    is it wise to extend the core this way? i know i could write like abstract Public_Controller and extend this one, but there are more than one controller types in fuel.
  • I haven't got a clue that you're trying to achieve, so maybe you can start by explaining that? I don't really have time to go through some CI code to find out. If if it's about having language codes in your URI's, add some code to your index.php or app bootstrap.php that will check $_SERVER (Fuel uses PATH_INFO, ORIG_PATH_INFO or REQUEST_URI, in this sequence), get the language code out of the URI, strip it, and passes the URI on without. If you store the extracted language code in a constant, you can set the language in your config.php to
    defined('YOUR_CONSTANT') ? YOUR_CONSTANT : 'en',
    

    This method will be completely transparent for your application, no single line of code needs to be changed. And it works for any application. Add the code above to it and you'll have i18n support directly.
  • Harro, if you have time please take a look at https://github.com/keevitaja/fuel-i18n i didn't feel like working with raw php (removing the language segment worked offcause as you described) while i have classes like Uri:: and Lang:: with "static constructors" which are incredible. am i inventing the bicycle all over again or is my approach reasonable?

Howdy, Stranger!

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

In this Discussion