Nested Language Files in Laravel 5

28th May 2016 | Tags:

In ear­lier ver­sions of Lar­avel, you were able to use dot nota­tion to refer to lan­guage lines in sub-​directories of your trans­la­tions directory.

So in other words, given the fol­low­ing file structure:

resources
  lang
    en
      site.php
      admin
        settings
          site.php

…you could refer to a line named title in resources/lang/en/admin/settings/site.php like this:

admin.settings.site.title

This no longer works in Lar­avel 5. It’s entirely pos­si­ble, how­ever — it’s just not obvi­ous, nor par­tic­u­larly well documented.

All you need to do is use forward-​slashes, for example:

admin/settings/site.title

That’s it.

Comments

No comments yet.

Links and images are allowed, but please note that rel="nofollow" will be automactically appended to any links.