¨4.0.1¨
This commit is contained in:
@@ -18,17 +18,19 @@ class TranslationLoader extends FileLoader
|
||||
return array_merge([$this->path], $this->hints);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the messages for the given locale.
|
||||
*
|
||||
* @param string $locale
|
||||
* @param string $group
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function load($locale, $group, $namespace = null)
|
||||
{
|
||||
if (! config('app.cache')) {
|
||||
if (!config('app.cache')) {
|
||||
return $this->getTranslations($locale, $group, $namespace);
|
||||
}
|
||||
|
||||
@@ -38,12 +40,14 @@ class TranslationLoader extends FileLoader
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get file and database translations.
|
||||
*
|
||||
* @param string $locale
|
||||
* @param string $group
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getTranslations($locale, $group, $namespace)
|
||||
@@ -60,10 +64,49 @@ class TranslationLoader extends FileLoader
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get database translations.
|
||||
*
|
||||
* @param string $locale
|
||||
* @param string $group
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function databaseTranslations($locale, $group, $namespace)
|
||||
{
|
||||
return Translation::where('key', 'LIKE', "{$namespace}::{$group}.%")
|
||||
->whereHas('translations', function ($query) use ($locale) {
|
||||
$query->where('locale', $locale);
|
||||
})->get()->mapWithKeys(function ($translation) use ($namespace, $group) {
|
||||
$key = str_replace("{$namespace}::{$group}.", '', $translation->key);
|
||||
|
||||
return [$key => $translation->value];
|
||||
})->all();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get file translations.
|
||||
*
|
||||
* @param string $locale
|
||||
* @param string $group
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function fileTranslations($locale, $group, $namespace)
|
||||
{
|
||||
return parent::load($locale, $group, $namespace);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Break flattened dot translations to an array.
|
||||
*
|
||||
* @param array $translations
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function breakDot($translations)
|
||||
@@ -80,37 +123,4 @@ class TranslationLoader extends FileLoader
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file translations.
|
||||
*
|
||||
* @param string $locale
|
||||
* @param string $group
|
||||
* @param string $namespace
|
||||
* @return array
|
||||
*/
|
||||
private function fileTranslations($locale, $group, $namespace)
|
||||
{
|
||||
return parent::load($locale, $group, $namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get database translations.
|
||||
*
|
||||
* @param string $locale
|
||||
* @param string $group
|
||||
* @param string $namespace
|
||||
* @return array
|
||||
*/
|
||||
private function databaseTranslations($locale, $group, $namespace)
|
||||
{
|
||||
return Translation::where('key', 'LIKE', "{$namespace}::{$group}.%")
|
||||
->whereHas('translations', function ($query) use ($locale) {
|
||||
$query->where('locale', $locale);
|
||||
})->get()->mapWithKeys(function ($translation) use ($namespace, $group) {
|
||||
$key = str_replace("{$namespace}::{$group}.", '', $translation->key);
|
||||
|
||||
return [$key => $translation->value];
|
||||
})->all();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user