Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Lang configuration with DB
  • Hi All :)
    I have a problem configuring the Lang with DB. I have created the table as the Docs.

    I have added in config.php this line:
    'language'  => array('lang.db')

    After that i set my desired language in the controller:
    Config::set('language','es');
    I have this line in DB Table:
    INSERT INTO `lang` (`identifier`, `language`, `lang`, `hash`) VALUES
    ('inicio', 'es', 'Inicio', 'hash');
    And i try to get a line with:
    Lang::get('inicio')
    But it always return NULL, my table name is 'lang'.

    What i'm doing wrong? 
  • I forget to say that in my controller i set the lang with:

    Config::set('language','es');
  • Language runs in the request context, so it depends on where you have used

    Lang::get('inicio');

    And where you have loaded it. So a bit more information is needed.
  • The 

    Config::set('language','es'); 

    is used in my controller (action_index at the moment for testing).

    And the 

    Lang::get('inicio') 

    Is used in the View directly  " echo Lang::get('inicio') "

    Besides that, what is the purpose of "hash" column in the Db?

    The 'language'  => array('lang.db') is in app/config/config.php
  • Ok, I get It.

    I did not know that the data is need be serialiced before save.


  • And you need to load it before you can use it. Language data isn't loaded automatically.
  • Thanks Harro, now I understand how it works.
  • HarroHarro
    Accepted Answer
    Cool. Happy coding! ;-)

Howdy, Stranger!

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

In this Discussion