Note that there are some explanatory texts on larger screens.

plurals
  1. POApp's locale files affect Engine's locale files. It force to have the same files in the hosting app. How fix it?
    text
    copied!<p>I experience strange behavior in my app with engine. App's locale translation files affect engines's ones. </p> <p>To make engine's files work I have to explicitly create the same files in the app. Just to name them the same an put empty locale hash in them is enough.</p> <p>This is my engine's locale directory. I have <code>.rb</code> files with translations (not <code>.yml</code>): </p> <pre><code># the directory: engine/config/locale | -- en.rb -- ru.rb # Translation files. ru.rb is the same. # en.rb { :en =&gt; { :foo =&gt; { :bar =&gt; "Bar", }, }, } </code></pre> <p>I my engine's views I call translations this way:</p> <pre><code>&lt;%= t("foo.bar") %&gt; </code></pre> <p>The problem is that I have to have absolutely the same files in my hosting app. If app's <code>/config/locales/</code> directory is empty (no <code>en.rb</code> and <code>ru.rb</code> files) then I have <code>I18n::InvalidLocaleData</code> error even if engine's <code>/config/locales/</code> looks as above (both files are present and correct).</p> <p>These translation files of the app can have different content but they have to be present and have to have the same locale key (<code>:en</code> or <code>:ru</code>). For example, this is enough for engine's files to work correctly:</p> <pre><code># app's translation files. ru.rb is the same. # en.rb { :en =&gt; { # even no content may be at all but an :en key has to be present }, }, } </code></pre> <p>How to fix this behavior? I don't want to explicitly create the same files in hosting app. I just want to have it empty, only engine let have its own translations. Because it causes an additional inconvenience for the users of the engine. </p>
 

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