本文整理汇总了PHP中Translator::getTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::getTranslator方法的具体用法?PHP Translator::getTranslator怎么用?PHP Translator::getTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translator
的用法示例。
在下文中一共展示了Translator::getTranslator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* DuplicateTranslationException Constructor
*
* @param string $language The language the translation is for
* @param string $phraseid The phrase id for the translation
* @param string $duplicate The duplicate translation
*/
public function __construct($language, $phraseid, $translation)
{
// Let the parent set us up
parent::__construct();
// Access the translator
$translator = Translator::getTranslator();
// Complete the error message
$this->message = sprintf($this->message, $language, $phraseid, $translator->translate($phraseid, $language), $translation);
}
示例2: __construct
/**
* SWException Constructor
*/
public function __construct($message = null, $args = null)
{
parent::__construct();
//TODO: This probably results in running translate twice - needed a quick fix
$message = Translator::getTranslator()->translateString($message);
if (!is_null($args) && is_array($args)) {
// Insert arguments into message
foreach ($args as $i => $arg) {
$message = str_replace("{" . $i . "}", $arg, $message);
}
}
if (isset($message)) {
$this->message = $message;
}
}
示例3: solidworks
/**
* SolidWorks (entry point)
*
* This function serves as the entry point for the entire application. It opens
* the session, loads the Page object, processes any forms, and invokes any actions
* for the page.
*
* @package SolidWorks
* @author John Diamond <jdiamond@solid-state.org>
*/
function solidworks(&$conf, $smarty)
{
global $page;
// Make the Page object available to smarty_extensions
global $translations;
// Make sure the client is logged in as a valid user before proceeding
validate_client();
// Load the user's language preference
$language = isset($_SESSION['client']['userdbo']) ? $_SESSION['client']['userdbo']->getLanguage() : null;
if ($language != null) {
TranslationParser::load("language/" . $language);
Translator::getTranslator()->setActiveLanguage($language);
}
if ($_SESSION['currentpage'] != $_GET['page']) {
$_SESSION['lastpage'] = $_SESSION['currentpage'];
}
// Get a Page object for the page being requested
$page = null;
$page = get_page_object($conf, $smarty);
if ($page == null) {
// Delete current session
session_destroy();
// Instantiate a generic page object
$page = new Page();
}
// Make sure the client has access to this page
if (!$page->control_access()) {
// Access denied
$page->setError(array("type" => "ACCESS_DENIED"));
$page->goback(1);
}
// Process any forms
if ($_SERVER['REQUEST_METHOD'] == "POST") {
handle_post_request();
}
// Execute any action if present in the URL
if (isset($_GET['action'])) {
$page->action($_GET['action']);
}
// Display
display_page($page);
// Push page onto the navigation stack
$_SESSION['navstack'][] = array("page" => $page->getName(), "url" => $page->getURL());
}
示例4: smarty_page_messages
/**
* Smarty Page Messages
*
* Output any page messages
*
* @param array $params Tag parameters
* @param string $content Content of tags
* @param object &$smarty Reference to the Smarty template
* @param boolean &$repeat Repeat flag
* @returns string Table HTML
*/
function smarty_page_messages($params, &$smarty)
{
global $conf, $page;
$messages = $_SESSION['messages'];
if (!isset($messages)) {
// No messages to display
return null;
}
// Build message box HTML
$html = "<p class=\"message\">\n";
// Write all the error messages currently in the session
$translator = Translator::getTranslator();
foreach ($messages as $message_data) {
// Insert arguments into error message
$message = $translator->translateString($message_data['type']);
if (isset($message_data['args'])) {
foreach ($message_data['args'] as $i => $arg) {
$message = str_replace("{" . $i . "}", $arg, $message);
}
}
$html .= $message . "<br/>\n";
}
$html .= "</p>\n";
// Remove messages from session
unset($_SESSION['messages']);
return $html;
}
示例5: loadModules
/**
* Load Modules
*/
public function loadModules()
{
global $conf;
if (!($dh = opendir($this->modulesPath))) {
throw new SWException("Could not access the modules directory: " . $this->modulesPath);
}
// Read the contents of the modules directory
while ($file = readdir($dh)) {
$moduleName = $file;
$moduleDir = sprintf("%s%s", $this->modulesPath, $moduleName);
$moduleConfFile = sprintf("%s/module.conf", $moduleDir);
$moduleClassFile = sprintf("%s/%s.class.php", $moduleDir, $moduleName);
$moduleDefTransFile = sprintf("%s/language/english", $moduleDir);
$moduleActTransFile = sprintf("%s/language/%s", $moduleDir, Translator::getTranslator()->getActiveLanguage());
if (is_dir($moduleDir) && (isset($file) && $file != "." && $file != "..") && file_exists($moduleClassFile)) {
// Load the module's config file
if (file_exists($moduleConfFile)) {
$modConf = load_config_file($moduleConfFile);
$conf['pages'] = array_merge($conf['pages'], $modConf['pages']);
$conf['forms'] = array_merge($conf['forms'], $modConf['forms']);
$conf['hooks'] = array_merge($conf['hooks'], $modConf['hooks']);
// Load the module's default translation file
if (file_exists($moduleDefTransFile)) {
TranslationParser::load($moduleDefTransFile);
}
// Load the module's active translation file
if ($moduleDefTransFile != $moduleActTransFile && file_exists($moduleActTransFile)) {
TranslationParser::load($moduleActTransFile);
}
}
// Load the module's class file
require $moduleClassFile;
// Initialize module
$module = new $moduleName();
$module->init();
$this->registerModule($module);
}
}
closedir($dh);
}
示例6: update_user
/**
* Update User
*/
function update_user()
{
if ($_SESSION['client']['userdbo']->getUsername() == $this->get['user']->getUsername() && $this->post['type'] != $this->get['user']->getType()) {
// Client can not change his own user type
$this->session['edit_user']['type'] = $this->get['user']->getType();
throw new SWUserException("[USER_TYPE_CHANGE]");
}
// Load form contents into DBO
$this->get['user']->setContactName($this->post['contactname']);
$this->get['user']->setEmail($this->post['email']);
$this->get['user']->setType($this->post['type']);
$this->get['user']->setLanguage($this->post['language']);
$this->get['user']->setTheme($this->post['theme']);
// Commit changes
update_UserDBO($this->get['user']);
// Success - Display message
$this->setMessage(array("type" => "[USER_UPDATED]", "args" => array($this->get['user']->getUsername())));
// Load language preference
$_SESSION['client']['userdbo'] = $this->get['user'];
Translator::getTranslator()->setActiveLanguage($this->get['user']->getLanguage());
$_SESSION['jsFunction'] = "reloadMenu()";
$this->gotoPage("config_edit_user", null, "user=" . $this->get['user']->getUsername());
}
示例7: __construct
/**
* Translation Parser Constructor
*/
public function __construct()
{
// Get access to the Translator
$this->translator = Translator::getTranslator();
$this->translator->setDefaultLanguage("english");
}
示例8: dirname
* @copyright John Diamond <jdiamond@solid-state.org>
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
*/
// Load config file
require_once dirname(__FILE__) . "/../config/config.inc.php";
// Load SolidWorks
require_once dirname(__FILE__) . "/../solidworks/solidworks.php";
// Load settings from database
require_once dirname(__FILE__) . "/../util/settings.php";
load_settings($conf);
require_once dirname(__FILE__) . "/../include/SolidStateMenu.class.php";
// Set the current theme
$theme = isset($_SESSION['client']['userdbo']) ? $_SESSION['client']['userdbo']->getTheme() : $conf['themes']['manager'];
$conf['themes']['current'] = $theme;
// Load the user's language preference
session_start();
$language = isset($_SESSION['client']['userdbo']) ? $_SESSION['client']['userdbo']->getLanguage() : null;
if ($language != null) {
TranslationParser::load("language/" . $language);
Translator::getTranslator()->setActiveLanguage($language);
}
// Change the charset to UTF-8
header("Content-type: text/html; charset=utf-8");
// Build the core menu
$menu = SolidStateMenu::getSolidStateMenu();
$username = isset($_SESSION['client']['userdbo']) ? $_SESSION['client']['userdbo']->getUsername() : null;
$menu->addItem(new SolidStateMenuItem("myinfo", "[MY_INFO]", "vcard_edit.png", "manager_content.php?page=config_edit_user&user=" . $username), "administration");
$menuItems = $menu->getItemArray();
$smarty->assign("menuItems", $menuItems);
// Display menu
$smarty->display(Page::selectTemplateFile("manager_menu.tpl"));
示例9: setError
/**
* Set Error
*
* Set an error in the Page session
*
* @param array $error Error data
*/
function setError($error)
{
$_SESSION['errors'][] = $error;
// Insert arguments into message
// TODO: This probably results in running translate twice - needed a quick fix
$text = Translator::getTranslator()->translateString($error['type']);
if (isset($error['args'])) {
foreach ($error['args'] as $i => $arg) {
$text = str_replace("{" . $i . "}", $arg, $text);
}
}
log_error($this->getClassName(), $text);
}
示例10: load_settings
/**
* Load Settings
*
* Load the application settings from the database
*
* @param array $conf Configuration data
*/
function load_settings(&$conf)
{
$DB = DBConnection::getDBConnection();
// Build Query
$sql = $DB->build_select_sql("settings", "*");
// Run Query
if (!($result = @mysql_query($sql, $DB->handle()))) {
throw new DBException(mysql_error($DB->handle()));
}
while ($setting = mysql_fetch_array($result)) {
$key = $setting['setting'];
$val = $setting['value'];
switch ($key) {
case "company_name":
$conf['company']['name'] = $val;
break;
case "company_email":
$conf['company']['email'] = $val;
break;
case "company_notification_email":
$conf['company']['notification_email'] = $val;
break;
case "order_confirmation_email":
$conf['order']['confirmation_email'] = $val;
break;
case "order_confirmation_subject":
$conf['order']['confirmation_subject'] = $val;
break;
case "order_notification_email":
$conf['order']['notification_email'] = $val;
break;
case "order_notification_subject":
$conf['order']['notification_subject'] = $val;
break;
case "welcome_email":
$conf['welcome_email'] = $val;
break;
case "welcome_subject":
$conf['welcome_subject'] = $val;
break;
case "nameservers_ns1":
$conf['dns']['nameservers'][0] = $val;
break;
case "nameservers_ns2":
$conf['dns']['nameservers'][1] = $val;
break;
case "nameservers_ns3":
$conf['dns']['nameservers'][2] = $val;
break;
case "nameservers_ns4":
$conf['dns']['nameservers'][3] = $val;
break;
case "invoice_text":
$conf['invoice_text'] = $val;
break;
case "invoice_subject":
$conf['invoice_subject'] = $val;
break;
case "locale_language":
TranslationParser::load("language/" . $val);
Translator::getTranslator()->setActiveLanguage($val);
$conf['locale']['language'] = $val;
break;
case "locale_currency_symbol":
$conf['locale']['currency_symbol'] = $val;
break;
case "payment_gateway_default_module":
$conf['payment_gateway']['default_module'] = $val;
break;
case "payment_gateway_order_method":
$conf['payment_gateway']['order_method'] = $val;
break;
case "order_accept_checks":
$conf['order']['accept_checks'] = $val;
break;
case "order_title":
$conf['order']['title'] = $val;
break;
case "order_tos_required":
$conf['order']['tos_required'] = $val;
break;
case "order_tos_url":
$conf['order']['tos_url'] = $val;
break;
case "theme_manager":
$conf['themes']['manager'] = $val;
break;
case "theme_order":
$conf['themes']['order'] = $val;
break;
}
}
}