I wrote a script with Laravel 5.3 that checks if a lang key exists in a giving language at run time. If the key does not exists, it will add it to the file.
However, if the first time around the key does not exists and I add it, then I do another check "during the same request" to see if the key exists, it will say it does not exist. So the loaded languages will not be aware that I added new keys to the file since Laravel loaded the keys in memory and I am only writing to the file on the hard-disk.
when I evaluate the Illuminate\Translation\Translator
class I see that the load method checks if a groups is load it does not load it again.
Here is the Laravel Code
/**
* Load the specified language group.
*
* @param string $namespace
* @param string $group
* @param string $locale
* @return void
*/
public function load($namespace, $group, $locale)
{
if ($this->isLoaded($namespace, $group, $locale)) {
return;
}
// The loader is responsible for returning the array of language lines for the
// given namespace, group, and locale. We'll set the lines in this array of
// lines that have already been loaded so that we can easily access them.
$lines = $this->loader->load($locale, $group, $namespace);
$this->loaded[$namespace][$group][$locale] = $lines;
}
Is there a way to force Laravel to read the language each time I request? Or, is there a way to add a key to the currently-in-memory keys? How can I tell laravel that I added new keys?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire