use Cubist\Backpack\Facades\App;
use Cubist\Backpack\Magic\Models\Translate;
use Cubist\Util\Files\Files;
+use Cubist\Util\Json;
use Cubist\Util\PHP;
use Illuminate\Support\Facades\Cache;
public static function getAllTranslations($force = true)
{
if (null === static::$_allTranslations) {
-
-
$cacheKey = static::_getCacheKey();
- if ($force) {
+ if (true || $force) {
Cache::forget($cacheKey);
}
static::$_allTranslations = Cache::remember($cacheKey, 3600, function () {
start_measure('Get all ' . static::$_name . ' translations !');
+ /** @var ToolboxBaseTranslate $t */
$t = static::find(1);
try {
$json = json_decode($t->getRawOriginal('content_translatable'), true, 512, JSON_THROW_ON_ERROR);
$res[$code][$k] = ['str' => static::keyToStr($k), 'translation' => $v];
}
}
+
+ foreach ($t->getAttributes() as $k => $item) {
+ if (in_array($k, ['content_translatable', 'id', 'deleted_at', 'created_at', 'updated_at', 'created_ok'])) {
+ continue;
+ }
+ $v = $item;
+ if (Json::isJson($v)) {
+ $v = json_decode($v, true);
+ }
+ if (is_scalar($v)) {
+ continue;
+ }
+ foreach ($v as $locale => $str) {
+ if (isset($res[$locale])) {
+ $res[$locale][$k] = ['str' => $k, 'translation' => $str];
+ }
+ }
+
+ }
+
stop_measure('Get all ' . static::$_name . ' translations !');
return $res;