laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Fix nested directory structure for translation files #2629

Open shadow81627 opened 3 years ago

shadow81627 commented 3 years ago

Laravel localization doesn't follow the usual "dot notation" for files in nested directories. When using the dot notation with nested directories translation key is returned. Such edit to docs was suggested already in July 2016 (#14212). -amadeann

This behavior is not intentional and thus may not be supported in the future so would rather not document it. -taylorotwell Source

Either prevent nested directory structure access or document the functionality.

The translation string files may be nested in subdirectories:

    /resources
        /lang
            /en
                /welcome
                    messages.php
            /es
                /welcome
                    messages.php

In this case the translation strings will be referenced by specifying the full path. For example:

    {{ __('welcome/messages.welcome') }}

    @lang('welcome/messages.welcome')

Documentation Source code Stackoverflow