本文整理汇总了PHP中I18n::getCurrentLangCode方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::getCurrentLangCode方法的具体用法?PHP I18n::getCurrentLangCode怎么用?PHP I18n::getCurrentLangCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I18n
的用法示例。
在下文中一共展示了I18n::getCurrentLangCode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDefaultLangName
public function getDefaultLangName($lang = null)
{
if ($lang == null) {
$do = BizSystem::getObject("myaccount.do.PreferenceDO", 1);
$rec = $do->fetchOne("[user_id]='0' AND [name]='language'");
if ($rec) {
$lang = $rec['value'];
} else {
$lang = DEFAULT_LANGUAGE;
}
}
$current_locale = I18n::getCurrentLangCode();
require_once 'Zend/Locale.php';
$locale = new Zend_Locale($current_locale);
$display_name = Zend_Locale::getTranslation($lang, 'language', $locale);
if ($display_name) {
return $display_name;
} else {
if ($lang) {
return $lang;
} else {
return DEFAULT_LANGUAGE;
}
}
}
示例2: render
/**
* Render element, according to the mode
*
* @return string HTML text
*/
public function render()
{
BizSystem::clientProxy()->includeCKEditorScripts();
$elementName = $this->m_Name;
$value = $this->getValue();
$value = htmlentities($value, ENT_QUOTES, "UTF-8");
$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::getCurrentLangCode();
$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;
}
示例3: __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::getCurrentLangCode();
$localeCode = $GLOBALS["local"][$currentLanguage];
setlocale(LC_ALL, $localeCode);
$this->_localeInfo = localeconv();
if ($this->_localeInfo['frac_digits'] > 10) {
$this->_localeInfo = null;
}
}
示例4: getFormatCurrency
public function getFormatCurrency($amount, $prefix = '')
{
$current_locale = I18n::getCurrentLangCode();
/*
switch($current_locale)
{
case "zh_CN":
$display_amount = "¥ ";
break;
case "en_US":
default:
$display_amount = "$ ";
break;
}
$display_amount.= number_format(floatval($amount));
return $prefix.$display_amount;
*/
setlocale(LC_MONETARY, $current_locale . '.utf8');
if (function_exists("money_format") && false) {
$display_amount = money_format('%n', (double) $amount);
} else {
$locale_info = localeconv();
if (!$locale_info[currency_symbol]) {
setlocale(LC_MONETARY, $current_locale);
$locale_info = localeconv();
}
$display_amount = $locale_info[currency_symbol] . ' ' . sprintf("%.2f", (double) $amount);
}
return $prefix . $display_amount;
/*
//Zend Currency is crazy slow
require_once('Zend/Currency.php');
$current_currency = DEFAULT_CURRENCY;
if(!$current_currency){
$current_currency = "USD";
}
$currency = new Zend_Currency($current_currency,$current_locale);
$amount = floatval($amount);
$display_name = $currency->toCurrency($prefix.$amount);
return $display_name;
*/
}
示例5: loadLangData
protected static function loadLangData($module)
{
if (isset(I18n::$_langData[$module])) {
return true;
}
// get language code
$langCode = I18n::getCurrentLangCode();
// load language file
if ($module == '_system') {
$filename = 'system.ini';
} else {
$filename = "mod.{$module}.ini";
}
$langFile = LANGUAGE_PATH . "/{$langCode}/{$filename}";
//echo "check ini file $langFile".nl;
if (!file_exists($langFile)) {
return false;
}
//echo "parse ini file $langFile".nl;
$inidata = parse_ini_file($langFile, false);
I18n::$_langData[$module] = $inidata;
//print_r(I18n::$_langData);
return true;
}
示例6: getZendTemplate
/**
* Get Zend Template
* @return Zend_View zend view template object
*/
public static function getZendTemplate()
{
// now assign the book data to a Zend_View instance
//Zend_Loader::loadClass('Zend_View');
require_once 'Zend/View.php';
$view = new Zend_View();
if (defined('SMARTY_TPL_PATH')) {
$view->setScriptPath(SMARTY_TPL_PATH);
}
$theme = Resource::getCurrentTheme();
// load the config file which has the images and css url defined
$view->app_url = APP_URL;
$view->app_index = APP_INDEX;
$view->js_url = JS_URL;
$view->css_url = THEME_URL . "/" . $theme . "/css";
$view->resource_url = RESOURCE_URL;
$view->theme_js_url = THEME_URL . "/" . $theme . "/js";
$view->theme_url = THEME_URL . "/" . $theme;
$view->image_url = THEME_URL . "/" . $theme . "/images";
$view->lang = strtolower(I18n::getCurrentLangCode());
return $view;
}
示例7: getAppendedStyles
/**
* Get appended styles
*
* @return string
*/
public function getAppendedStyles($comb = 0)
{
$extraStyles = implode("", $this->_extraStyles);
$extraStyle_array = explode("type=\"text/css\">", $extraStyles);
if (defined("RESOURCE_PHP") && $comb) {
$css_scripts = RESOURCE_PHP . "?f=";
foreach ($extraStyle_array as $style) {
// extract href part from each line
if (preg_match('/.+href="([^"]+)".+/', $style, $matches) > 0 && !empty($matches[1])) {
if (substr($css_scripts, -2) == 'f=') {
$css_scripts .= $matches[1];
} else {
$css_scripts .= ',' . $matches[1];
}
}
}
return "<link rel=\"stylesheet\" href=\"" . $css_scripts . "\" type=\"text/css\"/>";
}
$cleanStyle_array = array();
foreach ($extraStyle_array as $style) {
if (in_array($style . "type=\"text/css\">", $cleanStyle_array) == FALSE and strlen($style) != 0) {
$cleanStyle_array[] = $style . "type=\"text/css\">";
}
}
//added by Jixian for supports localization display styles
// eg.: override button width for specified languages
$lang = I18n::getCurrentLangCode();
$localization_css_file = APP_HOME . DIRECTORY_SEPARATOR . "languages" . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR . "localization.css";
if (is_file($localization_css_file)) {
$cleanStyle_array[] = "<link rel=\"stylesheet\" href=\"" . APP_URL . "/languages/{$lang}/localization.css\" type=\"text/css\">";
}
return implode("\n", $cleanStyle_array);
}
示例8: AddLangData
public static function AddLangData($from_module, $to_module = null)
{
if ($to_module == null) {
$to_module = $from_module;
}
$langCode = I18n::getCurrentLangCode();
$filename = "mod.{$from_module}.ini";
$langFile = LANGUAGE_PATH . "/{$langCode}/{$filename}";
if (!file_exists($langFile)) {
return false;
}
$inidata = parse_ini_file($langFile, false);
if (is_array(I18n::$_langData[$to_module])) {
I18n::$_langData[$to_module] = array_merge(I18n::$_langData[$to_module], $inidata);
} else {
I18n::$_langData[$to_module] = $inidata;
}
return true;
}