Created
July 17, 2018 13:46
-
-
Save dlhck/d795f782ac648e0accccb9cb03819d2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Helper; | |
use Pimcore\Config; | |
use Pimcore\Db; | |
class TranslationsDumper | |
{ | |
public function dump() | |
{ | |
$res = Db::get()->fetchAll("SELECT * FROM translations_website"); | |
$translations = []; | |
foreach ($res as $key => $translation) { | |
if (in_array($translation['language'], $this->getAvailableLanguages())) { | |
$translations[$translation['language']][$translation['key']] = $translation['text'] ? $translation['text'] : $translation['key']; | |
} | |
} | |
return $translations; | |
} | |
/** | |
* @return array | |
*/ | |
protected function getAvailableLanguages() | |
{ | |
try { | |
$general = Config::getSystemConfig()->get('general'); | |
return explode(',', $general->get('validLanguages')); | |
} catch (\Exception $e) { | |
return []; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment