Answers.Body: <p>You can include custom translation categories within your <code>config/app.php</code></p>
  
  <pre><code>return [
      'modules' =&gt; [
          'my-module' =&gt; \modules\Module::class,
      ],
      'components'    =&gt; [
          'i18n' =&gt; [
              'translations' =&gt; [
                  'foo'  =&gt; [
                      'class'            =&gt; \craft\i18n\PhpMessageSource::class,
                      'forceTranslation' =&gt; true,
                      'basePath'         =&gt; '@translations',
                  ],
              ]
          ]
      ]
      //'bootstrap' =&gt; ['my-module'],
  ];
  </code></pre>
  
  <p>This will include the custom group <code>foo</code> to your app, make sure to change the <code>basePath</code> variable to a path you like</p>
  
  <p>That being said your folder structure will look like</p>
  
  <pre><code>-your base path
  |-- en-US
  |-----&gt; foo.php
  |-- de-DE
  |-----&gt; foo.php
  </code></pre>
  
  <p>within these files you can create your custom translations</p>
  
  <pre><code>return [
      'foo' =&gt; 'bar'
  ];
  
  
  {{ 'foo'|t('foo') }} -&gt; will now display bar
  {{ 'foo'|t('site') }} -&gt; will still show foo
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-19T06:42:44.897Z
Answers.Text: I was actually hoping for something to be possible inside the translation-files themselves. Like creating arrays as groups with sub-arrays as sub-groups, or something like that. The sections I'd like to keep grouped don't have many different keys and are for small parts of the website instead of different (big) components. So this seem to be a little overkill for this purpose. That said; very good to know this is possible though and thanks a lot for your detailed and clear explanation on this. Don't know about loadtimes, but being able to do this in the config looks very flexible! Thanks
Answers.UserDisplayName: Friksel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-19T06:47:19.720Z
Answers.Text: According to your answer it looks to me you're very informed about the matter in Craft. And there's no answer telling this can be done from inside the translationfiles themselves. Next to this there's no reaction on the second part of my question about the possibility to add placeholders to the translation-strings to dynamically insert strings inside the template during a translationcall, so I guess that's not possible in Craft (yet?). So I mark your answer as the right answer.
Answers.UserDisplayName: Friksel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-19T07:14:12.697Z
Answers.Text: Oh sorry I forgot to answer about the 2nd part... It is possible to include placeholders you can do that via `{{ 'go to page {title}'|t('site', {title: entry.title} }}` just add an object as your 2nd parameter. They keys must match with the words inside `{ }` and those values will replace them.
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-19T18:29:08.453Z
Answers.Text: Cool @RobinSchambach ! Thanks a lot for this addition. I'll definitely gonna use that one! :)
Answers.UserDisplayName: Friksel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-15T16:24:57.563Z
Answers.LastActivityDate: 2018-07-15T16:24:57.563Z
Answers.UserDisplayName: Robin Schambach
Body: <p>At the moment I'm converting a website from a different CMS to Craft v3. The 'old' CMS had a convenient way to set a hierarchy for static translations in yaml files so that we could split translations into groups per section on the website.</p>
  
  <p>Like this:</p>
  
  <pre><code>  PageNavigation:
      PrevPage: 'Previous'
      NextPage: 'Next'
      GotoPrevPage: "Goto previous page: '{prevPageTitle}'"
  </code></pre>
  
  <p>Now I can't find anything like that on the documentation and google search on Craft CMS. At the moment this is what I got instead:</p>
  
  <pre><code>&lt;?php
  
  return array(
      'PageNavigation.PrevPage' =&gt; 'Previous',
      'PageNavigation.NextPage'=&gt; 'Next'
      'PageNavigation.GotoPrevPage' =&gt; "Goto previous page: '{prevPageTitle}'"
  );
  </code></pre>
  
  <p>So every translation-item has a group supplied to it as a prefix, followed by a dot and then the translation-itemID. But this gets ugly soon and is not as convinient as what I was used to in the other CMS.</p>
  
  <p><strong>1)</strong>
  <strong>Does anybody here perhaps knows if CraftCMS has a better way of setting hierarchy to static translations?</strong> So to group translation items to sections/elements on the website?</p>
  
  <p><strong>2)</strong>
  Is there a way in Craft CMS to have a placeholder inside the translation-string being replaced by a variable inside the template?</p>
  
  <p>In the 'old' CMS I could replace a placeholder like {placeholder} inside a translation-string by a dynamic variable inside the template. So a translation string like "Goto previous page: '{prevPageTitle}'" would come out as "Goto previous page: 'all about craft blog title'". <strong>Is there some functionality build in Craft that could replace a placeholder in the translation-string by a dynamic string?</strong></p>
  
  <p>Thanks in advance!!</p>
  
Tags: <localization>
Title: Is there some way to create sections inside static translations? (craft v3)
ThreadText: # Is there some way to create sections inside static translations? (craft v3)
  
  (Asked by: username_0 on 2018-07-15)
  
  At the moment I'm converting a website from a different CMS to Craft v3. The 'old' CMS had a convenient way to set a hierarchy for static translations in yaml files so that we could split translations into groups per section on the website.
  
  Like this:
  
  ```
    PageNavigation:
      PrevPage: 'Previous'
      NextPage: 'Next'
      GotoPrevPage: "Goto previous page: '{prevPageTitle}'"
  
  ```
  
  Now I can't find anything like that on the documentation and google search on Craft CMS. At the moment this is what I got instead:
  
  ```
  <?php
  
  return array(
      'PageNavigation.PrevPage' => 'Previous',
      'PageNavigation.NextPage'=> 'Next'
      'PageNavigation.GotoPrevPage' => "Goto previous page: '{prevPageTitle}'"
  );
  
  ```
  
  So every translation-item has a group supplied to it as a prefix, followed by a dot and then the translation-itemID. But this gets ugly soon and is not as convinient as what I was used to in the other CMS.
  
  **1)**
  **Does anybody here perhaps knows if CraftCMS has a better way of setting hierarchy to static translations?** So to group translation items to sections/elements on the website?
  
  **2)**
  Is there a way in Craft CMS to have a placeholder inside the translation-string being replaced by a variable inside the template?
  
  In the 'old' CMS I could replace a placeholder like {placeholder} inside a translation-string by a dynamic variable inside the template. So a translation string like "Goto previous page: '{prevPageTitle}'" would come out as "Goto previous page: 'all about craft blog title'". **Is there some functionality build in Craft that could replace a placeholder in the translation-string by a dynamic string?**
  
  Thanks in advance!!
  
  **Tags:** localization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-07-15. Score: 5 | Accepted answer
  
  You can include custom translation categories within your `config/app.php`
  
  ```
  return [
      'modules' => [
          'my-module' => \modules\Module::class,
      ],
      'components'    => [
          'i18n' => [
              'translations' => [
                  'foo'  => [
                      'class'            => \craft\i18n\PhpMessageSource::class,
                      'forceTranslation' => true,
                      'basePath'         => '@translations',
                  ],
              ]
          ]
      ]
      //'bootstrap' => ['my-module'],
  ];
  
  ```
  
  This will include the custom group `foo` to your app, make sure to change the `basePath` variable to a path you like
  
  That being said your folder structure will look like
  
  ```
  -your base path
  |-- en-US
  |-----> foo.php
  |-- de-DE
  |-----> foo.php
  
  ```
  
  within these files you can create your custom translations
  
  ```
  return [
      'foo' => 'bar'
  ];
  
  {{ 'foo'|t('foo') }} -> will now display bar
  {{ 'foo'|t('site') }} -> will still show foo
  
  ```
  
  > **Comments:**
  > **username_0**: I was actually hoping for something to be possible inside the translation-files themselves. Like creating arrays as groups with sub-arrays as sub-groups, or something like that. The sections I'd like to keep grouped don't have many different keys and are for small parts of the website instead of different (big) components. So this seem to be a little overkill for this purpose. That said; very good to know this is possible though and thanks a lot for your detailed and clear explanation on this. Don't know about loadtimes, but being able to do this in the config looks very flexible! Thanks  
  > **username_0**: According to your answer it looks to me you're very informed about the matter in Craft. And there's no answer telling this can be done from inside the translationfiles themselves. Next to this there's no reaction on the second part of my question about the possibility to add placeholders to the translation-strings to dynamically insert strings inside the template during a translationcall, so I guess that's not possible in Craft (yet?). So I mark your answer as the right answer.  
  > **username_1**: Oh sorry I forgot to answer about the 2nd part... It is possible to include placeholders you can do that via `{{ 'go to page {title}'|t('site', {title: entry.title} }}` just add an object as your 2nd parameter. They keys must match with the words inside `{ }` and those values will replace them.  
  > **username_0**: Cool @username_1 ! Thanks a lot for this addition. I'll definitely gonna use that one! :)  
  
  ---
  
  