Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
language
  • hi
    i must change my app for support multi language
    how can i do it? (fuelphp 1.9)
    i need language show in uri like : http\\sitename\en\module\controller\action
    and load language file by this uri prefix?
    but no idea how to set uri prefix language and get it without change in my old uri address

  • HarroHarro
    Accepted Answer
    To make sure I understand you, do you want to convert

    http\\sitename\en\module\controller\action

    to

    http\\sitename\module\controller\action

    and \Lang::set_lang('en');

    ?
  • HarroHarro
    Accepted Answer
    Ok.

    It isn't the best solution, as it makes it difficult to generate links in the application (which now are language dependent). Using a separate language cookie is a better solution, as you can manage the language selection completely different from the code of the app.

    Simply add this to your app bootstrap, after the Fuel::init() call: http://bin.fuelphp.com/snippet/view/NF
  • HarroHarro
    Accepted Answer
    this is how our app framework does it.

    We have the 'supported languages' actually in a lang file, since we use that to create a dropdown in the app page header so the user can select another language. The controller action that is called will then also set the cookie. We use this action: http://bin.fuelphp.com/snippet/view/NG
  • thanks, yes i see, can i set lang prefix in main app config file and then use it?
  • Language is already there.

Howdy, Stranger!

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

In this Discussion