Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Lang-loading from Module
  • Hey,

    Is it possible to load a lang-string from Module? 

    My module named "tasks":

    modules
    -config
    --config.php
    -lang
    --tasks.php

    config.php: 

    <?php

    return array(

    'always_load'  => array(

    'language'  => array(
    'tasks'
    )
    ),

    );


    tasks.php:

    <?php

    return array(
    'actions' => array(
    'added_task' => 'Befehl hinzugefügt'
    )
    );


    when i want to get a string using:

    echo Lang::get('tasks::tasks.actions.added_task');

    it doesnt work.

    hope you can help me :( 

    greez
  • HarroHarro
    Accepted Answer
    The language string container is global, so it doesn't matter from where you load a language file, you always access them the same way. They are not prefixed with a module or anything.

    You can not load a language file from a specific module, modules are supposed to be self-contained, so only access the data in the module from a controller inside the module. If you really need it, the proper way is to do an HMVC call to the module to load it.

    The workaround is to specify a fully qualified filename: APPPATH.'modules/mymodule/lang/en/actions.php and use that to load. But it is not recommended practice.

Howdy, Stranger!

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

In this Discussion