Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Advice about DB Localization
  • Hey,
    I have post with title, summary and content, I'd would like manage with localization (french and english), what is the best way to do ? Via database (EAV, belong) or Config/lang ?
    Actually I manage my IU fuel with Lang setup.
  • Harro VertonHarro Verton
    Accepted Answer
    My 2ct's:

    That depends who is in charge of the localisation. If that is the developer, and the localisation strings are static, I would use lang files, the default in Fuel.

    If the localisation strings are dynamic and edited by the user of the app (so your app has a GUI for localisation), database is probably better.
  • Yeah UI localisation is managed by developer so Iam with Lang config files.
    Posts localisation is managed by backend user, so I will go via database. thx
  • Iam trying to translate the post model data through an 'event after load', in my model :

    public function _event_after_load() {

            $this->name = $this->slug; // I translate here, $this->slug is just a test
    }

    $this->name stay $this->name and its not changed in slug, I missed something ? maybe it need an observer?
  • Harro VertonHarro Verton
    Accepted Answer
    It needs Observer_Self to run observer events in the model class itself.
  • Great thank again
  • How I can detect when 'name', 'summary' or 'content' property is called from _event_after_load ?
    or maybe I can call a event function per property ('property' => 'summary') ?
  • Harro VertonHarro Verton
    Accepted Answer
    What do you mean? What exactly do you want to do (functionally)?

    The event is just triggered once, after the record is loaded.
  • I though it was necessary to separe the event logic to each of the properties I need (name, summary and content). I want call its EAV container for find localisation.
    for exemple for name property in my _event_after_load function :
    $lang = \Session::get('lang');
    $property = 'name_'.$lang;
    $this->name = $this->$property;
  • Harro VertonHarro Verton
    Accepted Answer
    No, there is only one __event_after_load call: https://github.com/fuel/orm/blob/1.9/develop/classes/model.php#L944
  • Thanks, it works great.

Howdy, Stranger!

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

In this Discussion