function language_selector($params, &$smarty) { $languageTool =& Dataface_LanguageTool::getInstance(); echo $languageTool->getLanguageSelectorHtml($params); }
function df_load_realm($realm, $lang = null) { Dataface_LanguageTool::getInstance($lang)->loadRealm($realm); }
function translate($__translation_id, $__defaultText = null, $params = array(), $lang = null) { if (isset($this) and is_a($this, 'Dataface_LanguageTool') and $this->lang == $lang) { $tool =& $this; } else { $tool =& Dataface_LanguageTool::getInstance($lang); } $__found_text = null; foreach (array_reverse(array_keys($tool->realms)) as $realmName) { if (isset($tool->realms[$realmName][$__translation_id])) { $__found_text = $tool->realms[$realmName][$__translation_id]; break; } } if (!isset($__found_text) and isset($tool->dictionary[$__translation_id])) { $__found_text = $tool->dictionary[$__translation_id]; } if (isset($__found_text)) { if (!$params or @$params['__noreplace__']) { return $__found_text; } // make sure that there are no conflicting variable names as we are about to extract the params // array into local scope. if (isset($params['__translation_id'])) { unset($params['__translation_id']); } if (isset($params['tool'])) { unset($params['tool']); } if (isset($params['__defaultText'])) { unset($params['__defaultText']); } if (isset($params['params'])) { unset($params['params']); } if (isset($params['__found_text'])) { unset($params['__found_text']); } extract($params); @eval('$parsed = <<<END' . "\n" . $__found_text . "\nEND\n;"); if (!isset($parsed)) { return $__defaultText; } return $parsed; } if ($tool->lang != $tool->app->_conf['default_language']) { return $tool->translate($__translation_id, $__defaultText, $params, $tool->app->_conf['default_language']); } return $__defaultText; }