Non ricevo it! .. Può piacere qualcuno spiegare, come tradurre le etichette dei moduli? Un semplice esempio sarebbe fantastico.Come tradurre le etichette dei moduli in Zend Framework 2?
Grazie in anticipo!
classe Search \ Form \ CourseSearchForm
...
class CourseSearchForm extends Form {
...
public function __construct(array $cities) {
parent::__construct('courseSearch');
...
$this->add(array(
'name' => 'city',
'type' => 'Zend\Form\Element\Select',
'options' => array(
'label' => 'Stadt',
'value_options' => $this->cities,
'id' => 'searchFormCity',
),
));
...
}
}
vista sceneggiatura /module/Search/view/search/search/search-form.phtml
<?php echo $this->form()->openTag($form); ?>
<dl>
...
<dt><label><?php echo $form->get('city')->getLabel(); ?></label></dt>
<dd><?php echo $this->formRow($form->get('city'), null, false, false); ?></dd>
...
</dl>
<?php echo $this->form()->closeTag(); ?>
<!-- The formRow(...) is my MyNamespace\Form\View\Helper (extends Zend\Form\View\Helper\FormRow); the fourth argument of it disables the label. -->
module/Application/config/module.config.php
è configurato:
return array(
'router' => ...
'service_manager' => array(
'factories' => array(
'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
),
),
'translator' => array(
'locale' => 'de_DE',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'controllers' => ...
'view_manager' => ...
);
ho anche modificato il mio visualizzare e utilizzare il FormLabel
view helper:
<dt><label><?php echo $this->formLabel($form->get('city')); ?></label></dt>
Inoltre ho il debug del FormLabel
nel luogo, dove viene utilizzato il tranlator (linee 116-120) - - sembra essere OK.
Ma non funziona ancora.
EDIT
L'(test) articoli per le etichette, ho aggiunto al file de_DE.po
manualmente, sono tranlated. Il problema di ZF2 era in realtà, che stavo usando $form->get('city')->getLabel()
invece di $this->formlabel($form->get('city'))
nello script di visualizzazione th.
Il problema è ora che le etichette non vengono aggiunte al file de_DE.po
. Ma non è più un problema ZF2, quindi ho accettato la risposta di Ruben e ho aperto una nuova domanda su Poedit.
Si prega di aggiungere del codice di quello che si ha attualmente. Sarà più facile aiutarti e vedere qual è il problema. – Ruben
Grazie per una risposta veloce! Ho aggiunto il codice rilevante ora. – automatix