本文整理汇总了PHP中I18n::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::getInstance方法的具体用法?PHP I18n::getInstance怎么用?PHP I18n::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I18n
的用法示例。
在下文中一共展示了I18n::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createLocalUser
/**
* Creates a new local user in the application data base.
*
* @param WebSoccer $websoccer Application context.
* @param DbConnection $db DB Connection.
* @param string $nick User name of new user. Optional if e-mail address is provided. Must be unique in local data base. Case sensitive.
* @param string $email E-mail address of new user. Optional if nick is provided. Must be unique in local data base. Case insensitive (will be stored with lower letters).
* @throws Exception if both nick and e-mail are blank, or if nick name or e-mail address is already in use. Messages are not internationalized. Method assumes appropriate checks before calling it.
* @return int ID of newly created user.
*/
public static function createLocalUser(WebSoccer $websoccer, DbConnection $db, $nick = null, $email = null)
{
$username = trim($nick);
$emailAddress = strtolower(trim($email));
// check if either nick or e-mail is provided. If not, it most probably is a wrong API call,
// hence message is not required to be translated.
if (!strlen($username) && !strlen($emailAddress)) {
throw new Exception("UsersDataService::createBlankUser(): Either user name or e-mail must be provided in order to create a new internal user.");
}
// verify that there is not already such a user. If so, the calling function is wrongly implemented, hence
// no translation of message.
if (strlen($username) && self::getUserIdByNick($websoccer, $db, $username) > 0) {
throw new Exception("Nick name is already in use.");
}
if (strlen($emailAddress) && self::getUserIdByEmail($websoccer, $db, $emailAddress) > 0) {
throw new Exception("E-Mail address is already in use.");
}
// creates user.
$i18n = I18n::getInstance($websoccer->getConfig("supported_languages"));
$columns = array("nick" => $username, "email" => $emailAddress, "status" => "1", "datum_anmeldung" => $websoccer->getNowAsTimestamp(), "lang" => $i18n->getCurrentLanguage());
if ($websoccer->getConfig("premium_initial_credit")) {
$columns["premium_balance"] = $websoccer->getConfig("premium_initial_credit");
}
$db->queryInsert($columns, $websoccer->getConfig("db_prefix") . "_user");
// provide ID of created user.
if (strlen($username)) {
$userId = self::getUserIdByNick($websoccer, $db, $username);
} else {
$userId = self::getUserIdByEmail($websoccer, $db, $emailAddress);
}
// trigger plug-ins
$event = new UserRegisteredEvent($websoccer, $db, I18n::getInstance($websoccer->getConfig("supported_languages")), $userId, $username, $emailAddress);
PluginMediator::dispatchEvent($event);
return $userId;
}
示例2: initialize
/**
* initialize method
*
* Merge settings and set Config.language to a valid locale
*
* @return void
* @access public
*/
function initialize(&$Controller, $config = array())
{
App::import('Vendor', 'Mi.MiCache');
$lang = MiCache::setting('Site.lang');
if (!$lang) {
if (!defined('DEFAULT_LANGUAGE')) {
return;
}
$lang = DEFAULT_LANGUAGE;
} elseif (!defined('DEFAULT_LANGUAGE')) {
define('DEFAULT_LANGUAGE', $lang);
}
Configure::write('Config.language', $lang);
App::import('Core', 'I18n');
$I18n =& I18n::getInstance();
$I18n->domain = 'default_' . $lang;
$I18n->__lang = $lang;
$I18n->l10n->get($lang);
if (!empty($Controller->plugin)) {
$config['plugins'][] = Inflector::underscore($Controller->plugin);
}
if (!empty($config['plugins'])) {
$plugins = array_intersect(MiCache::mi('plugins'), $config['plugins']);
$Inst = App::getInstance();
foreach ($plugins as $path => $name) {
$Inst->locales[] = $path . DS . 'locale' . DS;
}
}
}
示例3: readMetadata
/**
* Read Metadata from xml array
* @param array $xmlArr
*/
protected function readMetadata(&$xmlArr)
{
parent::readMetaData($xmlArr);
$this->m_InheritFrom = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["INHERITFROM"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["INHERITFROM"] : null;
$this->m_Title = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["TITLE"]) ? I18n::getInstance()->translate($xmlArr["BIZFORM"]["ATTRIBUTES"]["TITLE"]) : null;
$this->m_Description = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["DESCRIPTION"]) ? I18n::getInstance()->translate($xmlArr["BIZFORM"]["ATTRIBUTES"]["DESCRIPTION"]) : null;
//added by Jixian
$this->m_SearchRule = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["SEARCHRULE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["SEARCHRULE"] : null;
$this->m_BaseSearchRule = $this->m_SearchRule;
$this->m_jsClass = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["JSCLASS"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["JSCLASS"] : null;
$this->m_Height = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["HEIGHT"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["HEIGHT"] : null;
$this->m_Width = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["WIDTH"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["WIDTH"] : null;
$this->m_Range = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["PAGESIZE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["PAGESIZE"] : null;
$this->m_FullPage = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["FULLPAGE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["FULLPAGE"] : null;
$this->m_Stateless = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["STATELESS"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["STATELESS"] : null;
$this->m_Style = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["STYLE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["STYLE"] : 'display: block';
//Get the style of a form from xml --jmmz
$this->m_Name = $this->prefixPackage($this->m_Name);
$this->m_DataObjName = $this->prefixPackage($xmlArr["BIZFORM"]["ATTRIBUTES"]["BIZDATAOBJ"]);
$this->m_DisplayModes = new MetaIterator($xmlArr["BIZFORM"]["DISPLAYMODES"]["MODE"], "DisplayMode");
$this->m_RecordRow = new RecordRow($xmlArr["BIZFORM"]["BIZCTRLLIST"]["BIZCTRL"], "FieldControl", $this);
$this->m_ToolBar = new ToolBar($xmlArr["BIZFORM"]["TOOLBAR"]["CONTROL"], "HTMLControl", $this);
$this->m_NavBar = new NavBar($xmlArr["BIZFORM"]["NAVBAR"]["CONTROL"], "HTMLControl", $this);
$this->m_Parameters = new MetaIterator($xmlArr["BIZFORM"]["PARAMETERS"]["PARAMETER"], "Parameter");
}
示例4: render
/**
* Render element, according to the mode
*
* @return string HTML text
*/
public function render()
{
BizSystem::clientProxy()->includeCKEditorScripts();
$elementName = $this->m_Name;
$value = $this->getValue();
$style = $this->getStyle();
$width = $this->m_Width ? $this->m_Width : 600;
$height = $this->m_Height ? $this->m_Height : 300;
//$func = "onclick=\"editRichText('$elementName', $width, $height);\"";
if (!strlen($value) > 0) {
// fix suggested by smarques
$value = " ";
}
$type = strtolower($this->m_Mode);
$fileBrowserPage = APP_URL . "/bin/filebrowser/browser.html";
$languageCode = I18n::getInstance()->getCurrentLanguage();
$languageCode = str_replace("_", "-", $languageCode);
$config = $this->m_Config;
$sHTML .= "<textarea id=\"{$elementName}\" name=\"{$elementName}\" >{$value}</textarea>\n";
$sHTML .= "<script type=\"text/javascript\">\n";
if ($config) {
//remove the last commas
$config = trim($config);
if (substr($config, strlen($config) - 1, 1) == ',') {
$config = substr($config, strlen($config) - 1);
}
$sHTML .= "Openbiz.CKEditor.init('{$elementName}',{'type':'{$type}','filebrowserBrowseUrl':'{$fileBrowserPage}','language':'{$languageCode}','height':'{$height}','width':'{$width}',{$config}});\n";
} else {
$sHTML .= "Openbiz.CKEditor.init('{$elementName}',{'type':'{$type}','filebrowserBrowseUrl':'{$fileBrowserPage}','language':'{$languageCode}','height':'{$height}','width':'{$width}'});\n";
}
$sHTML .= "</script>\n";
return $sHTML;
}
示例5: __construct
/**
* Initialize FieldControl with xml array
*
* @param array $xmlArr xml array
* @param BizForm $formObj BizForm instance
* @return void
*/
function __construct(&$xmlArr, $formObj)
{
parent::__construct($xmlArr, $formObj);
$this->m_BizFormName = $formObj->m_Name;
$this->m_BizFieldName = isset($xmlArr["ATTRIBUTES"]["FIELDNAME"]) ? $xmlArr["ATTRIBUTES"]["FIELDNAME"] : null;
$this->m_DisplayName = isset($xmlArr["ATTRIBUTES"]["DISPLAYNAME"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["DISPLAYNAME"]) : null;
$this->m_Description = isset($xmlArr["ATTRIBUTES"]["DESCRIPTION"]) ? $xmlArr["ATTRIBUTES"]["DESCRIPTION"] : null;
$this->m_ValuePicker = isset($xmlArr["ATTRIBUTES"]["VALUEPICKER"]) ? $xmlArr["ATTRIBUTES"]["VALUEPICKER"] : null;
$this->m_PickerMap = isset($xmlArr["ATTRIBUTES"]["PICKERMAP"]) ? $xmlArr["ATTRIBUTES"]["PICKERMAP"] : null;
if (isset($xmlArr["ATTRIBUTES"]["DRILLDOWNLINK"])) {
$this->_setDrillDownLink($xmlArr["ATTRIBUTES"]["DRILLDOWNLINK"]);
}
$this->m_Enabled = isset($xmlArr["ATTRIBUTES"]["ENABLED"]) ? $xmlArr["ATTRIBUTES"]["ENABLED"] : null;
$this->m_Sortable = isset($xmlArr["ATTRIBUTES"]["SORTABLE"]) ? $xmlArr["ATTRIBUTES"]["SORTABLE"] : null;
$this->m_DataType = isset($xmlArr["ATTRIBUTES"]["DATATYPE"]) ? $xmlArr["ATTRIBUTES"]["DATATYPE"] : null;
$this->m_Order = isset($xmlArr["ATTRIBUTES"]["ORDER"]) ? $xmlArr["ATTRIBUTES"]["ORDER"] : null;
$this->m_DefaultValue = isset($xmlArr["ATTRIBUTES"]["DEFAULTVALUE"]) ? $xmlArr["ATTRIBUTES"]["DEFAULTVALUE"] : null;
$this->m_ColumnStyle = isset($xmlArr["ATTRIBUTES"]["COLUMNSTYLE"]) ? $xmlArr["ATTRIBUTES"]["COLUMNSTYLE"] : null;
$this->m_Mode = MODE_R;
// if no class name, add default class name. i.e. NewRecord => ObjName.NewRecord
$this->m_ValuePicker = $this->prefixPackage($this->m_ValuePicker);
if (!$this->m_BizFieldName) {
$this->m_BizFieldName = $this->m_Name;
}
}
示例6: getFromList
public function getFromList(&$list)
{
$current_locale = I18n::getInstance()->getCurrentLanguage();
$country = BizSystem::clientProxy()->getFormInputs("fld_region");
$country = strtoupper($country);
if (!$country) {
$locale = explode('_', $current_locale);
$country = strtoupper($locale[0]);
}
require_once 'Zend/Locale.php';
$locale = new Zend_Locale($current_locale);
$code2name = $locale->getTranslationList('territorytolanguage', $locale);
$list = array();
$i = 0;
foreach ($code2name as $key => $value) {
if (preg_match('/' . $country . '/', $value) || strtoupper($key) == $country) {
$lang_list = explode(" ", $value);
foreach ($lang_list as $lang) {
$list[$i]['txt'] = strtolower($key) . "_" . strtoupper($lang);
$list[$i]['val'] = strtolower($key) . "_" . strtoupper($lang);
$i++;
}
}
}
return $list;
}
示例7: readMetaData
protected function readMetaData(&$xmlArr)
{
parent::readMetaData($xmlArr);
$this->m_cssClass = isset($xmlArr["ATTRIBUTES"]["CSSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSCLASS"] : "input_text";
$this->m_cssErrorClass = isset($xmlArr["ATTRIBUTES"]["CSSERRORCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSERRORCLASS"] : $this->m_cssClass . "_error";
$this->m_cssFocusClass = isset($xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"] : $this->m_cssClass . "_focus";
$this->m_cssHoverClass = isset($xmlArr["ATTRIBUTES"]["CSSHOVERCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSHOVERCLASS"] : $this->m_cssClass . "_hover";
$this->m_Value = isset($xmlArr["ATTRIBUTES"]["DEFAULTVALUE"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["DEFAULTVALUE"]) : null;
$this->m_ReadOnly = isset($xmlArr["ATTRIBUTES"]["READONLY"]) ? $xmlArr["ATTRIBUTES"]["READONLY"] : "N";
}
示例8: __construct
/**
* Constructor of TypeManager, set locale with $localCode parameter
*
* @param string $localeCode
* @return void
**/
public function __construct($localeCode = "")
{
//try to set correct locale for current language as defined in app.inc section I18n
$currentLanguage = I18n::getInstance()->getCurrentLanguage();
$localeCode = $GLOBALS["local"][$currentLanguage];
setlocale(LC_ALL, $localeCode);
$this->_localeInfo = localeconv();
if ($this->_localeInfo['frac_digits'] > 10) {
$this->_localeInfo = null;
}
}
示例9: index
/**
*导航.
*/
public function index()
{
$n = $this->Navigation->findall();
// pr($n);
if (!class_exists('I18n')) {
App::import('Core', 'i18n');
}
$I18n =& I18n::getInstance();
echo $I18n->l10n->locale;
exit;
}
示例10: change
/**
* Action to change the current language
*
* The expected HTTP parameters are:
* <ul>
* <li>lang: lange to change to (via HTTP GET)</li>
* </ul>
*
* @return void
*/
public function change()
{
if (!isset($_GET["lang"])) {
throw new Exception("no lang parameter was provided");
}
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
I18n::getInstance()->setLanguage($_GET["lang"]);
// go back to previous page
header("Location: " . $_SERVER["HTTP_REFERER"]);
die;
}
示例11: readMetaData
/**
* Read array meta data, and store to meta object
*
* @param array $xmlArr
* @return void
*/
protected function readMetaData(&$xmlArr)
{
parent::readMetaData($xmlArr);
$this->m_FieldName = isset($xmlArr["ATTRIBUTES"]["FIELDNAME"]) ? $xmlArr["ATTRIBUTES"]["FIELDNAME"] : null;
$this->m_Label = isset($xmlArr["ATTRIBUTES"]["LABEL"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["LABEL"]) : null;
$this->m_Description = isset($xmlArr["ATTRIBUTES"]["DESCRIPTION"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["DESCRIPTION"]) : null;
$this->m_DefaultValue = isset($xmlArr["ATTRIBUTES"]["DEFAULTVALUE"]) ? $xmlArr["ATTRIBUTES"]["DEFAULTVALUE"] : null;
$this->m_Required = isset($xmlArr["ATTRIBUTES"]["REQUIRED"]) ? $xmlArr["ATTRIBUTES"]["REQUIRED"] : null;
$this->m_Enabled = isset($xmlArr["ATTRIBUTES"]["ENABLED"]) ? $xmlArr["ATTRIBUTES"]["ENABLED"] : null;
$this->m_Text = isset($xmlArr["ATTRIBUTES"]["TEXT"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["TEXT"]) : null;
// if no class name, add default class name. i.e. NewRecord => ObjName.NewRecord
$this->m_ValuePicker = $this->prefixPackage($this->m_ValuePicker);
}
示例12: render
public function render()
{
$func_up = $this->getBtnFunction('fld_sortorder_up');
$func_down = $this->getBtnFunction('fld_sortorder_down');
$formobj = $this->getFormObj();
//$this->m_EventHandlers = null;
$value = $this->m_Text ? $this->getText() : $this->m_Value;
if ($value == null || $value == "") {
return "";
}
$style = $this->getStyle();
$id = $this->m_Name;
if ($this->m_Translatable == 'Y') {
if (defined($value)) {
$value = constant($value);
}
$value = I18n::getInstance()->translate($value);
}
if ((int) $this->m_MaxLength > 0) {
if (function_exists('mb_strlen') && function_exists('mb_substr')) {
if (mb_strlen($value, 'UTF8') > (int) $this->m_MaxLength) {
$value = mb_substr($value, 0, (int) $this->m_MaxLength, 'UTF8') . '...';
}
} else {
if (strlen($value) > (int) $this->m_MaxLength) {
$value = substr($value, 0, (int) $this->m_MaxLength) . '...';
}
}
}
if ($value != null) {
if ($this->m_DisplayFormat) {
$value = sprintf($this->m_DisplayFormat, $value);
}
if ($this->m_Percent == 'Y') {
$value = sprintf("%.2f", $value * 100) . '%';
}
if ($this->m_Link) {
$link = $this->getLink();
$target = $this->getTarget();
//$sHTML = "<a href=\"$link\" onclick=\"SetOnLoadNewView();\" $style>" . $val . "</a>";
$sHTML = "<a id=\"{$id}\" href=\"{$link}\" {$target} {$func} {$style}>" . $value . "</a>";
} else {
$sHTML = "<span style=\"width:auto;height:auto;\" {$func}>" . $value . "</span>";
}
}
$sHTML = "<a {$func_up} class=\"arrow_up\" href=\"javascript:;\"></a> " . $sHTML . " <a {$func_down} class=\"arrow_down\" href=\"javascript:;\"></a>";
return $sHTML;
}
示例13: getFromList
public function getFromList(&$list)
{
require_once 'Zend/Locale.php';
$locale = new Zend_Locale(I18n::getInstance()->getCurrentLanguage());
$code2name = $locale->getTranslationList('territory', $locale, 2);
$list = array();
$i = 0;
foreach ($code2name as $key => $value) {
if ((int) $key == 0) {
$list[$i]['val'] = $key;
$list[$i]['txt'] = $value;
$i++;
}
}
return $list;
}
示例14: readMetadata
protected function readMetadata(&$xmlArr)
{
parent::readMetaData($xmlArr);
$this->m_Name = $this->prefixPackage($this->m_Name);
$this->m_Title = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TITLE"]) ? I18n::getInstance()->translate($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TITLE"]) : null;
$this->m_Description = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["DESCRIPTION"]) ? I18n::getInstance()->translate($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["DESCRIPTION"]) : null;
$this->m_CssClass = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["CSSCLASS"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["CSSCLASS"] : null;
$this->m_TemplateEngine = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TEMPLATEENGINE"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TEMPLATEENGINE"] : null;
$this->m_TemplateFile = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TEMPLATEFILE"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TEMPLATEFILE"] : null;
$this->m_StartMenuItem = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["STARTMENUITEM"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["STARTMENUITEM"] : null;
$this->m_StartMenuID = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["STARTMENUID"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["STARTMENUID"] : null;
$this->m_SearchRule = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["SEARCHRULE"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["SEARCHRULE"] : null;
$this->m_GlobalSearchRule = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["GLOBALSEARCHRULE"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["GLOBALSEARCHRULE"] : null;
$this->m_MenuDeep = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["MENUDEEP"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["MENUDEEP"] : null;
$this->m_DataObjName = $this->prefixPackage($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["BIZDATAOBJ"]);
$this->m_CacheLifeTime = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["CACHELIFETIME"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["CACHELIFETIME"] : "0";
}
示例15: fetchData
public function fetchData()
{
preg_match("/\\[([\\S]*?)\\]=\\'file_(.*?)\\'/si", $this->m_FixSearchRule, $match);
$Id = $match[2];
$resultArr = $this->fetchDataSet();
$record = $resultArr[$Id];
require_once 'Zend/Locale.php';
$locale = new Zend_Locale(I18n::getInstance()->getCurrentLanguage());
$code2name = $locale->getTranslationList('language', $locale);
$lang_code = $this->getLang();
$locale = explode('_', $lang_code);
$lang = $code2name[$locale[0]];
$image_path = APP_URL . "/images/nations/22x14/" . strtolower($locale[1]) . '.png';
$image = "<image style=\"float:left;display:block;margin-right:5px;padding-top:2px;\" src=\"{$image_path}\" />";
$record['lang'] = "<div>" . $image . " <span style=\"float:left;display:block;\">{$lang} ( {$lang_code} )</span></div>";
$record['translation'] = file_get_contents($record['path']);
$this->m_RecordId = "file_" . $Id;
return $record;
}