#!/usr/bin/php
<?php 
/**
 * languagess
 */
namespace CB;

use CB\L;
$path = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'httpsdocs' . DIRECTORY_SEPARATOR;
require_once $path . 'config_platform.php';
require_once LIB_DIR . 'language_functions.php';
// select main translations
$T = array();
$cfg = Config::getPlatformDBConfig();
$res = DB\dbQuery('SELECT *
    FROM ' . \CB\PREFIX . '_casebox.translations
    WHERE `type` in (0, 2)');
while ($r = $res->fetch_assoc()) {
    foreach ($r as $k => $v) {
        if (strlen($k) == 2 && $k != 'id' && !empty($v)) {
            $T[$k][] = "'" . $r['name'] . "':'" . addcslashes($v, "'") . "'";
        }
    }
}
$res->close();
//save each translations as main language file
saveFiles($T);
echo "main language files saved\n";
//iterate cores and collect those that have custom translations
$cores = array();
$res = DB\dbQuery('SELECT name, cfg