Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Multilanguage Support !
  • Hello to whoever can help me! I have never used ORM, and I'm having a hard time understanding if I can do what I want with Fuel's out of the box ORM Package. I decided to use ORM, instead of building all my query's this time.
    And i'm working on a E-Commerce Multi Language Website. I'm the kind of person who understands better at a clear example, which is what I ask of you.
    Here's a scheme example of my db Table: Products (id, category_id, etc..) Table: Products_t (id, name, ...., site_id or site_prefix)
    In Products_t: id would be Products id, and site_id or site_prefix would be an int of a language table or 'en_US' for example. I read up on google, and in Propel ORM we can do the following (good use of i18n)
    $items = ItemQuery::create() ->joinWithI18n('en_EN') ->find(); // one query to retrieve both all items and their translations foreach ($items as $item) { echo $item->getPrice(); echo $item->getName(); // no additional query }[/CODE] I know we can't do exactly this, but is there anywhere I can use my scheme (table products and products_t) and join the results using the site_prefix as filter? I'm still struggling with orm relationshops. It's nothing more then: [CODE] SELECT item.*, item_i18n.* FROM item LEFT JOIN item_i18n ON (item.id = item_i18n.id AND item_i18n.locale = 'en_EN'); [/CODE][CODE]$items = ItemQuery::create()
    ->joinWithI18n('en_EN')
    ->find(); // one query to retrieve both all items and their translations
    foreach ($items as $item) {
    echo $item->getPrice();
    echo $item->getName(); // no additional query
    }[/CODE] I know we can't do exactly this, but is there anywhere I can use my scheme (table products and products_t) and join the results using the site_prefix as filter?
    I'm still struggling with orm relationshops. It's nothing more then:
    SELECT item.*, item_i18n.* FROM item LEFT JOIN item_i18n ON (item.id = item_i18n.id AND item_i18n.locale = 'en_EN'); [/CODE][CODE]
    SELECT item.*, item_i18n.*
    FROM item LEFT JOIN item_i18n ON (item.id = item_i18n.id AND item_i18n.locale = 'en_EN');
    [/CODE]
  • How did you implement this?
  • EDIT: So i figured how it works in FUEL. But I would love that option to be able to just switch language with a function (like Propel), of course that would mean edit the Package and I think I lack the skill to do it. Anyone interested in implementing that feature?
    I'll try anyway
  • Isn't this just a simple where() clause on the join? And since all data is coming out of the database dynamically, what exactly does this propel function do? I would create a base model for all models that need i18n, add a static method that allows you to set the language, and use the _init() static method to set the default language to the language code active in Fuel. Then in the model I would create get() methods for the different queries, which internally run the query with the i18n join based on the language code set, and return the result. Your business logic can just call for example Model_Products::get_products() which will just return the product objects with the correct language strings.

Howdy, Stranger!

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

In this Discussion