Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Language dont work from Modules
  • Hey,

    When i want to call: 
    <?php echo Lang::get('tasks.possible_tasks.dl_exec.translation'); ?>
    It dont works.

    My lang-file at modules/tasks/lang/tasks.php:
    <?php

    return array(
    'possible_tasks' => array(
    'dl_exec' => array(
    'translation' => 'Herunterladen und ausführen',
    'fields' => array(
    'url' => 'Download-Link'
    )
    ),
    'update' => array(
    'translation' => 'Aktualisierung',
    'fields' => array(
    'url' => 'Download-Link'
    )
    ),
    'update_melt' => array(
    'translation' => 'Datei herunterladen, ausführen und Bot deinstallieren',
    'fields' => array(
    'url' => 'Download-Link'
    )
    )
    ),
    'status' => array(
    '1' => 'Aktiviert',
    '0' => 'Deaktiviert'
    )
    );

    My config at modules/tasks/config/config.php:
    <?php

    return array(

    'always_load'  => array(
    'classes' => array(
    'tasks'
    ),
    'config' => array(
    'possible_tasks'
    ),
    'language'  => array(
    'tasks'
    )
    ),

    );

    I know that i ask very much today, but i dont understand the Module-System ;-) FuelPHP is excelent documented but the Module system is a little bit "bad" documented.. Hope you can help me!

    Greez <3
  • HarroHarro
    Accepted Answer
    This is related to your other question, where I said you should not call classes directly.

    Modules operate in what is called a module context. This context is set automatically when the router determines you are calling a module controller, either via the browser or API (the main request), or via a HMVC request. A context is what allows a module controller to find local assets like config, lang, views, etc.

    If you just do a class load across namespace, the framework has no clue you're switching contexts, it is not involved in the calling process.

    Cross-module usage is considered very bad practice, not done, and it doesn't work (without quite a bit of hacking). And therefore not documented. It is in direct contradiction with the design philosophy of loose coupling. The fact that the autoloader is able to load the class doesn't mean that it (from a framework point of view) will work.

    If you need to access a module (or another module), the only proper way to do that is using an HMVC request.
  • But why cant i load langfiles or so from the module from the module? ;) "tasks" is located in the module?

    greez
  • HarroHarro
    Accepted Answer
    if you're in a module controller, and this controller is called either by a main Request or an HMVC Request, then loading a language file from that same module just works.

    So, where you do you the \Lang::load() call, and how did you get there?
  • I load the lang-file from the config at modules/tasks/config/config.php at always_load.. 


    greez
  • HarroHarro
    Accepted Answer
    Modules don't have a config file, so anything in there will be ignored.
  • Oh -.-

Howdy, Stranger!

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

In this Discussion