zendframework / ZendSkeletonApplication

Skeleton application for zend-mvc projects
BSD 3-Clause "New" or "Revised" License
1.51k stars 1.42k forks source link

More examples ? #83

Closed ghost closed 12 years ago

ghost commented 12 years ago

Hi there, I would be great that this module (or ZendSkeletonModule) show an example to:

David

EvanDotPro commented 12 years ago

@booradleys: The skeletons are not really meant to be full-fledged examples, but rather bare-bones starting points for your own code. (ie, something a CLI tool might create once we have one: zf create project ZendSkeletonApplication). For the examples you're looking for, you should check out modules like ZfcUser, etc. (Yes, we plan on adding translations to Zfcuser).

ghost commented 12 years ago

Hi Evan, Yes each time i need help, i'm looking for into zfcUser ;-) You did a real great job !

I'm looking how to implement I18n/Translator (into each Module.php of each module ?).
I'm using a wrong way (Registry) to pass data from I18n/Translator/Translator to I18n/View/Helper/Translate). But i suppose i should use service manager but i don't know how.

ghost commented 12 years ago

{code} public function initTranslator(Event $e) { $app = $e->getParam('application'); $locator = $app->getServiceManager(); $view = $locator->get('Zend\View\View'); $renderer = $locator->get('Zend\View\Renderer\PhpRenderer');

    $module = 'application';
    $lang = 'fr';

    $originalLocale = Locale::getDefault();
    Locale::setDefault($lang);

    $service = array(
            'name' => 'phpini',
            'class' => new \Mix\I18n\Translator\Loader\PhpIni(),
            'directory' => "module/".$module."/i18n/".$lang,
            'filename' => 'common.ini'
    );

    $options = array('locale' => $lang);
    $translator = \Zend\I18n\Translator\Translator::factory($options);
    $translator->getPluginManager()->setService($service['name'], $service['class']);
    $translator->addTranslationPattern($service['name'], $service['directory'], $service['filename']);

    $renderer->plugin('translate')->setTranslator($translator);
}

{code}

But when using i got : Translator has not been set

EvanDotPro commented 12 years ago

@booradleys See PR #1743. Once that's merged, it should simplify things quite a bit.

ghost commented 12 years ago

Thank you Evan. I'm going to wait for this merge (in beta5)