lundi 27 novembre 2017

L5.1 - Command with localization not working (not in Ubuntu but yes on Mac)

I have a command called SendReminders, when I change the locale with App::setLocale('locale') it looks like is working because when I do App::getLocale() returns the correct one, but when I call for a translation returns always the default localization.

This is my SendReminders class:

<?php namespace App\Console\Commands;

use Illuminate\Console\Command;

use App;
use Exception;
use Storage;
use Lang;

class SendReminders extends Command
{

    protected $signature = 'send:reminders';

    public function __construct(){
        parent::__construct();
    }

    public function handle(){

        App::setLocale('EN');
        echo App::getLocale()."\n"; // <= Shows correctly 'EN'
        echo Lang::get('general.contact')."\n"; // <= Shows correctly 'Contact'

        App::setLocale('DE');
        echo App::getLocale()."\n"; // <= Shows correctly 'DE'
        echo Lang::get('general.contact')."\n"; // <= Doesn't show the correct value

    }

}

I'm missing something to make the localization work?

EDIT:

Some estrange behavior is happening because on my Mac is working but on Linux (Ubuntu) is not, looks like is not finding my folder /resources/lang/de/



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire