Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I will quote the answer i have provided <a href="https://stackoverflow.com/questions/15782558/zf2-how-to-translate-zend-form-validation-error-messages#answer-15788091">right here</a>. I won't bother to edit the texts too much, so do not bother about some of the sentences, but the essence is important and will help you out a lot.</p> <p>The first thing to get Form-Translation working is to add files to the <code>translator</code></p> <p>When adding a new translator to your configuration, do <strong>NOT</strong> use the default translator-text-domain. The Syntax is as follows:</p> <pre><code>$translator-&gt;addTranslationFile( $type, $resource, $textDomain, //&lt;-- this is the important one $lang ); </code></pre> <p>In your example you've added a file to the default-textdomain. This, sadly, brings lots of troubles with it, at it will not always work as expected. Whenever you're adding translation files, add them to your own text-domain!</p> <p>After that, all you need to do is to assign the <code>Zend\Form\View\Helper</code> your text-domain. This is done by the following:</p> <pre><code>// For Labels $this-&gt;formLabel()-&gt;setTranslatorTextDomain('your-textdomain'); // For Buttons (input type submit) $this-&gt;formButton()-&gt;setTranslatorTextDomain('your-textdomain'); // For Error-Messages $this-&gt;formElementErrors()-&gt;setTranslatorTextDomain('your-textdomain'); </code></pre> <p><strong>About the Translator itself</strong></p> <p>Another thing to note is: as long as there is a Translator-Service attached to your configuration with the name <code>translator</code>, it will automatically be attached to the form as default translator. This is a sample configuration i use within my modules regularly:</p> <pre><code>'translator' =&gt; array( 'locale' =&gt; 'de_DE', 'translation_file_patterns' =&gt; array( array( 'type' =&gt; 'phparray', 'base_dir' =&gt; __DIR__ . '/lang', 'pattern' =&gt; '%s.php', 'text_domain' =&gt; __NAMESPACE__, ), ), ), </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload