<p dir="auto">For me, a increasingly common issue is that I have duplicate translation files. Let me explain with a use case:</p>
<p dir="auto">Given an entity named 'Article', say you want users to create articles on your website. To make that happen you create a form, and for convenience you set up a convention notation for each of the entity's fields:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# forms.en.yml
article:
  fields:
    title: Title
    summary: Summary
    body: Article text
    datetime_published: Publish at"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> forms.en.yml</span>
<span class="pl-ent">article</span>:
  <span class="pl-ent">fields</span>:
    <span class="pl-ent">title</span>: <span class="pl-s">Title</span>
    <span class="pl-ent">summary</span>: <span class="pl-s">Summary</span>
    <span class="pl-ent">body</span>: <span class="pl-s">Article text</span>
    <span class="pl-ent">datetime_published</span>: <span class="pl-s">Publish at</span></pre></div>
<p dir="auto">And the user sees nicely labeled fields at the form.</p>
<p dir="auto">Now imagine a CMS for this website, where you want to list the articles. The column names could be the same as above, but since the context is different, you'll want some translations to be different, like this:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# cms.en.yml
article:
  fields:
    title: Title
    summary: Summary
    body: Body
    datetime_published: Publication date"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> cms.en.yml</span>
<span class="pl-ent">article</span>:
  <span class="pl-ent">fields</span>:
    <span class="pl-ent">title</span>: <span class="pl-s">Title</span>
    <span class="pl-ent">summary</span>: <span class="pl-s">Summary</span>
    <span class="pl-ent">body</span>: <span class="pl-s">Body</span>
    <span class="pl-ent">datetime_published</span>: <span class="pl-s">Publication date</span></pre></div>
<p dir="auto">As your website gets larger and/or the number of entities grow, so do the duplicate translations. There are more use cases to think of where you'd want some sort of inheritance. Something that would work like this:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# domain.en.yml
article:
  fields:
    title: Title
    summary: Summary
    body: Body
    datetime_published: Publication date"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> domain.en.yml</span>
<span class="pl-ent">article</span>:
  <span class="pl-ent">fields</span>:
    <span class="pl-ent">title</span>: <span class="pl-s">Title</span>
    <span class="pl-ent">summary</span>: <span class="pl-s">Summary</span>
    <span class="pl-ent">body</span>: <span class="pl-s">Body</span>
    <span class="pl-ent">datetime_published</span>: <span class="pl-s">Publication date</span></pre></div>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# forms.en.yml
imports:
  - { resource: %kernel.root_dir%/../src/Acme/DemoBundle/Resources/translations/domain.en.yml }

article:
  fields:
    body: Article text
    datetime_published: Publish at"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> forms.en.yml</span>
<span class="pl-ent">imports</span>:
  - <span class="pl-s">{ resource: %kernel.root_dir%/../src/Acme/DemoBundle/Resources/translations/domain.en.yml }</span>

<span class="pl-ent">article</span>:
  <span class="pl-ent">fields</span>:
    <span class="pl-ent">body</span>: <span class="pl-s">Article text</span>
    <span class="pl-ent">datetime_published</span>: <span class="pl-s">Publish at</span></pre></div>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# cms.en.yml
imports:
  - { resource: %kernel.root_dir%/../src/Acme/DemoBundle/Resources/translations/domain.en.yml }"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span> cms.en.yml</span>
<span class="pl-ent">imports</span>:
  - <span class="pl-s">{ resource: %kernel.root_dir%/../src/Acme/DemoBundle/Resources/translations/domain.en.yml }</span></pre></div>
<p dir="auto">I have a working proof of concept in a project that's currently running in production. Basically I've extended the regular translation file loader with one that looks for imports in translations, and merges them with the rest of the translation file.</p>
<p dir="auto">I'm curious if this is something that more people want. Comments and feedback are welcome.</p>
<p dir="auto">So, back at square one i guess :)</p>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="189685529" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/20533" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/20533/hovercard" href="https://github.com/symfony/symfony/pull/20533">#20533</a> reverted the integrity check for accessing services, before the container builder is actually compiled. Making it real tricky, yet convenient. However, it is done for the right reasons, for now.</p>
<p dir="auto">Where does that leave us? Will it be put back? And what is the alternative/right approach?</p>
<p dir="auto">Imo. we all agree the check is needed to keep the container trusty, but we lose major flexibility on simple services (ones that can actually be resolved fully <strong>at some point</strong> before compilation).</p>
<p dir="auto">Some ideas;</p>
<ul dir="auto">
<li>(1) Keep it as is. If this was already decided by now, please close :) Basically saying to the user; with great power, comes great responsibility; do as you like / whatever works for you. Until it breaks that is :))</li>
<li>Deprecate it!
<ul dir="auto">
<li>(2) Teach the user to do a different approach in user-land (ie. just initialize a service hardcoded, where needed, when needed). As there will be many tickets about this i guess.</li>
<li>(3) Introduce a 2nd container, compiled and accessible, <em>before</em> compiling the 1st container. The  user can configure required services as usual. Ie. what about tagging required services with <code class="notranslate">bootstrap</code>, making the full service available on booting, ie. one config and no duplicate service definitions.</li>
<li>(4) Allow the user to get a service without compiling the current container (ie. clone it, compile it, then get it). However this basically acts the same as option 1 (keeping it as is), whenever it breaks / doesnt work anymore you still need to revise your approach.</li>
<li>(5) Detect which services are safe, and which arent out-of-the-box (the holy grail).</li>
<li>(6) Allow compiler passes to run last with scope on a (sub)compiled version of the container, still allowing to modify the actual container. Doing it in 2 steps, the other way around.</li>
</ul>
</li>
</ul>