Note that there are some explanatory texts on larger screens.

plurals
  1. PORails I18n nested translation keys
    primarykey
    data
    text
    <p>Is there a way to nest translation lookups? Something like this:</p> <pre><code>en: uh_oh: 'Uh Oh!' error1: :'uh_oh' + ' There was a big error!' error2: :'uh_oh' + ' There was another big error!' </code></pre> <pre class="lang-rb prettyprint-override"><code>I18n.t('error1') #=&gt; 'Uh Oh! There was a big error!' I18n.t('error2') #=&gt; 'Uh Oh! There was another big error!' </code></pre> <p>I've tried a bunch of variations of this, and also tried it using a Ruby translation file instead of YAML. Note that this <strong>does</strong> work:</p> <pre><code>en: uh_oh: 'Uh Oh!' error1: :'uh_oh' </code></pre> <pre class="lang-rb prettyprint-override"><code>I18n.t('error1') #=&gt; 'Uh Oh!' </code></pre> <p>But if I add additional text to <code>error1</code>, <code>uh_oh</code> doesn't get translated.</p> <p>Basically I want to avoid having to always pass in common terms, like this:</p> <pre><code>en: uh_oh: 'Uh Oh!' error1: '%{uh_oh} There was a big error!' </code></pre> <pre class="lang-rb prettyprint-override"><code>I18n.t('error1', {uh_oh: I18n.t('uh_oh')}) </code></pre> <p>For common terms like <code>uh_oh</code>, the interpolation is the same for every call to <code>error1</code> (and any other key that uses <code>uh_oh</code>), so it doesn't really make sense to have to pass in a string to be interpolated. It'd be easier to do the following instead and have the <code>error1</code> translation take care of the common key translation:</p> <pre class="lang-rb prettyprint-override"><code>I18n.t('error1') </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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