LaraBABA's avatar

Problems with language file

Hello,

My language file is not working on my local and remote. For example:

    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            @lang('crud.blogs.index_title')
        </h2>
    </x-slot>

Shows as:

    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            crud.blogs.index_title
        </h2>
    </x-slot>

I deleted the cache via:

php artisan cache:clear
php artisan view:clear
php artisan config:clear
php artisan config:cache

I checked the language file, it is well upload, anything else I should check please? I never this issue before.

I have the feeling that the /en/ folder not being taken into consideration: /laravel/lang/en/crud.php

Where may I tell the app to read directly into the en folder please?

Thanks

0 likes
14 replies
Sinnbeck's avatar

Are you absolutely sure that the file is called crud.php and not Crud.php or similar? Linux is case sensitive.

LaraBABA's avatar

@Sinnbeck I have updated my question with more details. Yes sure, the file is called crud.php

And sorry about that, but the issue now happens also on the local too(after deleting the cache). I must have changed something by mistake...ahhhh

LaraBABA's avatar

I checked GIT, no changes in that file. Here it is:

<?php

return [
    'common' => [
        'actions' => 'Actions',
        'create' => 'Create',
        'edit' => 'Edit',
        'update' => 'Update',
        'new' => 'New',
        'cancel' => 'Cancel',
        'attach' => 'Attach',
        'detach' => 'Detach',
        'save' => 'Save',
        'delete' => 'Delete',
        'delete_selected' => 'Delete selected',
        'search' => 'Search...',
        'back' => 'Back to Index',
        'are_you_sure' => 'Are you sure?',
        'no_items_found' => 'No items found',
        'created' => 'Successfully created',
        'saved' => 'Saved successfully',
        'imported' => 'File Successfully imported',
    ],
    'blogs' => [
        'name' => 'Blogs',
        'index_title' => 'Blogs List',
        'new_title' => 'New Blog',
        'create_title' => 'Create Blog',
        'edit_title' => 'Edit Blog',
        'show_title' => 'Show Blog',
        'inputs' => [
            'enabled' => 'Post Published?',
            'title' => 'Title',
            'slug' => 'Slug',
            'content' => 'Content',
            'launch_date' => 'Launch Date',
            'image1' => 'Image1',
            'image2' => 'Image2',
            'image3' => 'Image3',
        ],
    ],
];

Config/app.php

<?php

use Illuminate\Support\Facades\Facade;

return [

    /*
    |--------------------------------------------------------------------------
    | Application Name
    |--------------------------------------------------------------------------
    |
    | This value is the name of your application. This value is used when the
    | framework needs to place the application's name in a notification or
    | any other location as required by the application or its packages.
    |
    */

    'name' => env('APP_NAME', 'Laravel'),

    /*
    |--------------------------------------------------------------------------
    | Application Environment
    |--------------------------------------------------------------------------
    |
    | This value determines the "environment" your application is currently
    | running in. This may determine how you prefer to configure various
    | services the application utilizes. Set this in your ".env" file.
    |
    */

    'env' => env('APP_ENV', 'production'),

    /*
    |--------------------------------------------------------------------------
    | Application Debug Mode
    |--------------------------------------------------------------------------
    |
    | When your application is in debug mode, detailed error messages with
    | stack traces will be shown on every error that occurs within your
    | application. If disabled, a simple generic error page is shown.
    |
    */

    'debug' => (bool) env('APP_DEBUG', false),

    /*
    |--------------------------------------------------------------------------
    | Application URL
    |--------------------------------------------------------------------------
    |
    | This URL is used by the console to properly generate URLs when using
    | the Artisan command line tool. You should set this to the root of
    | your application so that it is used when running Artisan tasks.
    |
    */

    'url' => env('APP_URL', 'http://localhost'),

    'asset_url' => env('ASSET_URL'),

    /*
    |--------------------------------------------------------------------------
    | Application Timezone
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default timezone for your application, which
    | will be used by the PHP date and date-time functions. We have gone
    | ahead and set this to a sensible default for you out of the box.
    |
    */

    'timezone' => 'Europe/Vienna',

    /*
    |--------------------------------------------------------------------------
    | Application Locale Configuration
    |--------------------------------------------------------------------------
    |
    | The application locale determines the default locale that will be used
    | by the translation service provider. You are free to set this value
    | to any of the locales which will be supported by the application.
    |
    */

    'locale' => 'en',

    /*
    |--------------------------------------------------------------------------
    | Application Fallback Locale
    |--------------------------------------------------------------------------
    |
    | The fallback locale determines the locale to use when the current one
    | is not available. You may change the value to correspond to any of
    | the language folders that are provided through your application.
    |
    */

    'fallback_locale' => 'en',

    /*
    |--------------------------------------------------------------------------
    | Faker Locale
    |--------------------------------------------------------------------------
    |
    | This locale will be used by the Faker PHP library when generating fake
    | data for your database seeds. For example, this will be used to get
    | localized telephone numbers, street address information and more.
    |
    */

    'faker_locale' => 'en_US',

    /*
    |--------------------------------------------------------------------------
    | Encryption Key
    |--------------------------------------------------------------------------
    |
    | This key is used by the Illuminate encrypter service and should be set
    | to a random, 32 character string, otherwise these encrypted strings
    | will not be safe. Please do this before deploying an application!
    |
    */

    'key' => env('APP_KEY'),

    'cipher' => 'AES-256-CBC',

    /*
    |--------------------------------------------------------------------------
    | Maintenance Mode Driver
    |--------------------------------------------------------------------------
    |
    | These configuration options determine the driver used to determine and
    | manage Laravel's "maintenance mode" status. The "cache" driver will
    | allow maintenance mode to be controlled across multiple machines.
    |
    | Supported drivers: "file", "cache"
    |
    */

    'maintenance' => [
        'driver' => 'file',
        // 'store'  => 'redis',
    ],

    /*
    |--------------------------------------------------------------------------
    | Autoloaded Service Providers
    |--------------------------------------------------------------------------
    |
    | The service providers listed here will be automatically loaded on the
    | request to your application. Feel free to add your own services to
    | this array to grant expanded functionality to your applications.
    |
    */

    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,
        Barryvdh\Debugbar\ServiceProvider::class,

        /*
         * Package Service Providers...
         */

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
        App\Providers\TelescopeServiceProvider::class,

    ],

    /*
    |--------------------------------------------------------------------------
    | Class Aliases
    |--------------------------------------------------------------------------
    |
    | This array of class aliases will be registered when this application
    | is started. However, feel free to register as many as you wish as
    | the aliases are "lazy" loaded so they don't hinder performance.
    |
    */

    'aliases' => Facade::defaultAliases()->merge([
        // 'ExampleClass' => App\Example\ExampleClass::class,
    ])->toArray(),

];

LaraBABA's avatar

@Sinnbeck None of them are working, they all output the text as "crud.common.actions", this is weird.... It is like the @lang() fails totally to be read. But all the other blade code is working eg:

@if
@endif

@can....
LaraBABA's avatar

@Sinnbeck I found something....

I installed a package called "Laravel-share" and it seems to be adding this: resources\lang\vendor\laravel-share\en\laravel-share-fa5.php

I have the feeling that adding this here causes the app to read this and not the normal lang file....

I will try to delete the vendor file and see what happens.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@LaraBABA Can you check if you also have a lang folder inside the resources folder ?

3 likes
Sinnbeck's avatar

Yeah thats the old lang directory. You can only have 1. Delete /resources/lang

LaraBABA's avatar

@Sinnbeck Ok this was it :-(

I had to delete the whole resources\lang\ folder.

Not sure why adding this would cause a complete bypass of the original language file, any idea why please?

Thanks

Sinnbeck's avatar

@LaraBABA Because laravel used to have /resources/lang and now its /lang. So it first checks if you are using the old version (folder exists in /resources/lang) and ignores /lang if it does. So just move the files over, and delete the directory

1 like
LaraBABA's avatar

@Sinnbeck And thanks again for your help!

I added your answer as the correct one as you helped me a lot and it seems that we both looked at the resource issue at the same time lol.

Please or to participate in this conversation.