rememberForever(md5('translations.all'), function () { return self::getTranslations(); }); } /** * Get file translations. * * @return array */ public static function getFileTranslations() { $translations = []; foreach (resolve('translation.loader')->paths() as $hint => $path) { foreach (supported_locales() as $locale => $language) { foreach (glob("{$path}/{$locale}/*.php") as $file) { foreach (array_dot(require $file) as $key => $value) { $group = str_replace('.php', '', basename($file)); $translations["{$hint}::{$group}.{$key}"][$locale] = $value; } } } } return $translations; } /** * Get database translations. * * @return array */ public static function getDatabaseTranslations() { $translations = []; foreach (static::all() as $translation) { foreach ($translation->translations as $translationTranslation) { $translations[$translation->key][$translationTranslation->locale] = $translationTranslation->value; } } return $translations; } protected static function getTranslations() { return array_replace_recursive(static::getFileTranslations(), static::getDatabaseTranslations()); } }