- if (!empty($module)) {
- $this->init();
- //DB_DataObject::debugLevel(1);
- require_once 'Services/JSON.php';
- $d = DB_DataObject::factory('translations');
- $d->module = $module;
- $d->selectAdd();
- $d->selectAdd('distinct(tlang) as tlang');
- header('Content-type: text/javascript');
- $langs= $d->fetchAll('tlang');
- foreach($langs as $lang) {
- // output the translations strings file..
-
-
- $this->loadOriginalStrings($module);
-
- $data = $this->loadTranslateDB($lang,$module);
-
- $j = new Services_JSON();
- echo "_T.{$lang}= Roo.apply( _T.{$lang} || { }, " . $j->stringify($data, null, 4) . ");\n";
-
- }
- exit;
-
- }
-
- // load and parse json file containing all translations...
- if (isset($_REQUEST['id'])) {
- return $this->post();
- }
- if (empty($_REQUEST['lang']) || !preg_match('/^[A-Z_]+$/i', $_REQUEST['lang'])) {
- $this->jerr("NO LANG / INVALID LANG");
- }
-
- $enable = $this->modulesList();
-
- if (empty($_REQUEST['module']) || !in_array($_REQUEST['module'], $enable)) {
- $this->jerr("NO MODULE / INVALID MODULE");
- }
-
-
- $lang = $_REQUEST['lang'];
- $module = $_REQUEST['module'];
-
-
- $this->loadOriginalStrings($module); // what needs translating..
-
- $ff = $this->bootLoader;
- if (empty($ff->Pman['public_cache_dir'])) {
- $this->jerr("public_cache_dir has not been set up");
- }
-
-
-
- $translated_data = $this->loadTranslateDB($lang, $module); // the 'database!'
-
-
- // echo '<PRE>';print_R($data);exit;
- // covert data ready to send back..
-
- $ret = array();
- foreach($this->original as $k=>$ar) {
- foreach($ar as $tr=>$trv) {
- // $hint = isset($hints[$tr]) ? $hints[$tr] : '';
- $key = md5($k.'-'.$tr);
- $ret[] = array(
- 'id' => $lang.'/'.$key,
- 'msum' => $key,
- 'colname' => $k,
- 'origtxt' => $tr,
- 'txt' => isset($translated_data[$key]) ? $translated_data[$key] : '',
- // 'suggest' => $hint
- );
-
- }