本文整理汇总了PHP中kernel::get_lang方法的典型用法代码示例。如果您正苦于以下问题:PHP kernel::get_lang方法的具体用法?PHP kernel::get_lang怎么用?PHP kernel::get_lang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kernel
的用法示例。
在下文中一共展示了kernel::get_lang方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tmpl_file, $app_id = null, $fetch = false, $is_theme = false)
{
array_unshift($this->_files, $tmpl_file);
$this->_vars = $this->pagedata;
if ($p = strpos($tmpl_file, ':')) {
$object = kernel::service('tpl_source.' . substr($tmpl_file, 0, $p));
if ($object) {
$tmpl_file_path = substr($tmpl_file, $p + 1);
$last_modified = $object->last_modified($tmpl_file_path);
}
} else {
if (defined('CUSTOM_CORE_DIR') && file_exists(CUSTOM_CORE_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file)) {
$tmpl_file = CUSTOM_CORE_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file;
} else {
if (!$is_theme) {
$tmpl_file = realpath(APP_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file);
} else {
$tmpl_file = realpath(THEME_DIR . '/' . $tmpl_file);
}
}
$last_modified = filemtime($tmpl_file);
}
if (!$last_modified) {
//无文件
}
$this->tmpl_cachekey('__temp_lang', kernel::get_lang());
//设置模版所属语言包
$this->tmpl_cachekey('__temp_app_id', $app_id ? $app_id : $this->app->app_id);
$compile_id = $this->compile_id($tmpl_file);
#if($this->force_compile || base_kvstore::instance('cache/template')->fetch($compile_id, $compile_code, $last_modified) === false){
if ($this->force_compile || !cachemgr::get($compile_id . $last_modified, $compile_code)) {
if ($object) {
$compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path));
} else {
$compile_code = $this->_compiler()->compile_file($tmpl_file);
}
if ($compile_code !== false) {
#base_kvstore::instance('cache/template')->store($compile_id,$compile_code);
cachemgr::co_start();
cachemgr::set($compile_id . $last_modified, $compile_code, cachemgr::co_end());
}
}
ob_start();
eval('?>' . $compile_code);
$content = ob_get_contents();
ob_end_clean();
array_shift($this->_files);
$this->pre_display($content);
if ($fetch === true) {
return $content;
} else {
echo $content;
}
}
示例2: tips_item_by_app
static function tips_item_by_app($app_id)
{
$lang = kernel::get_lang();
$tips = array();
foreach (file(PUBLIC_DIR . '/app/' . $app_id . '/lang/' . $lang . '/tips.txt') as $tip) {
$tip = trim($tip);
if ($tip) {
$tips[] = $tip;
}
}
return $tips;
}
示例3: get_varys
public function get_varys()
{
$varys['HOST'] = kernel::base_url(true);
//host信息
$varys['REWRITE'] = defined('WITH_REWRITE') ? WITH_REWRITE : '';
//是否有rewirte支持
$varys['LANG'] = kernel::get_lang();
//语言环境
$varys['ECAE'] = ECAE_PUB_POINT;
//ecae布置环境
return $varys;
}
示例4: init_pack
public static function init_pack($app)
{
$current_lang = kernel::get_lang();
$lang_resource = $app->lang_resource;
if (is_array($lang_resource[$current_lang]) && in_array('config.php', $lang_resource[$current_lang])) {
self::$_langPack[$app->app_id] = (array) @(include $app->lang_dir . '/' . $current_lang . '/config.php');
} elseif (is_array($lang_resource['zh-cn']) && in_array('config.php', $lang_resource['zh-cn'])) {
self::$_langPack[$app->app_id] = (array) @(include $app->lang_dir . '/zh-cn/config.php');
} else {
//trigger_error('language pack is lost in '.$this->app_id, E_USER_ERROR);
self::$_langPack[$app->app_id] = array();
}
}
示例5: _
public static function _($lang_dir, $key, $args = null)
{
if (self::is_need_conv()) {
$language = kernel::get_lang();
putenv("LANG={$language}");
setlocale(LC_ALL, $language);
$domain = 'lang';
bindtextdomain($domain, $lang_dir);
textdomain($domain);
bind_textdomain_codeset($domain, 'utf-8');
return gettext($key);
} else {
return $key;
}
}
示例6: _
public static function _($lang_dir, $key, $args)
{
if (!is_string($key) || trim($key) == '') {
return '';
}
if (self::is_need_conv()) {
$language = kernel::get_lang();
putenv("LANG={$language}");
setlocale(LC_ALL, $language);
$domain = 'lang';
bindtextdomain($domain, $lang_dir);
textdomain($domain);
bind_textdomain_codeset($domain, 'utf-8');
}
if (count($args) > 1) {
return call_user_func_array("sprintf", $args);
} else {
return self::__($key);
}
}
示例7: parse_app
private function parse_app($app_id)
{
$app = app::get($app_id);
$lang = kernel::get_lang();
$dir = $app->lang_dir . '/' . $lang . '/LC_MESSAGES';
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
$file = $dir . '/lang.po';
$array = array();
/* $this->parse_php($app, $app->app_dir . '/controller', $array); */
/* $this->parse_php($app, $app->app_dir . '/dbschema', $array); */
/* $this->parse_php($app, $app->app_dir . '/model', $array); */
/* $this->parse_php($app, $app->app_dir . '/lib', $array); */
$this->parse_php($app, $app->app_dir . '/', $array);
$this->parse_html($app, $app->app_dir . '/view', $array);
$this->parse_html($app, $app->app_dir . '/lang/js', $array);
if (!empty($array)) {
$this->create_po_package($app_id, $file, $array);
logger::info(sprintf('%s 语言包转换文件生成成功,共 %d items', $app->app_id, count($array)));
} else {
logger::info(sprintf('%s 没有语言包', $app->app_id));
}
}
示例8: lang_css
function lang_css($params)
{
$default = array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen, projection');
$app = $params['app'] ? app::get($params['app']) : $this->app;
$lang = kernel::get_lang();
$src = 'css/' . $params['src'];
if (is_array($app->lang_resource[$lang]) && in_array($src, $app->lang_resource[$lang])) {
$file = $app->lang_url . '/' . $lang . '/' . $src;
} elseif (is_array($app->lang_resource['zh-cn']) && in_array($src, $app->lang_resource['zh-cn'])) {
$file = $app->lang_url . '/zh-cn/' . $src;
} else {
return '';
}
if (isset($params['src'])) {
unset($params['src']);
}
if (isset($params['app'])) {
unset($params['app']);
}
$params = count($params) ? $params + $default : $default;
foreach ($params as $k => $v) {
$ext .= sprintf('%s="%s" ', $k, $v);
}
$time = substr(cachemgr::ask_cache_check_version(), 0, 6);
$file = $file . '?' . $time;
return sprintf('<link href="%s" %s/>', $file, $ext);
}
示例9: lang_css
function lang_css($params)
{
$default = array('rel' => 'stylesheet', 'media' => 'screen, projection');
$app = $params['app'] ? app::get($params['app']) : $this->app;
$lang = kernel::get_lang();
$debug = defined('DEBUG_CSS') && constant('DEBUG_CSS');
if ($params['pdir'] && !$debug) {
$pdir = $params['pdir'];
} else {
$pdir = 'css';
}
$src = $pdir . '/' . $params['src'];
if (is_array($app->lang_resource($lang)) && in_array($src, $app->lang_resource($lang))) {
$file = $app->lang_url . '/' . $lang . '/' . $src;
} elseif (is_array($app->lang_resource('zh_CN')) && in_array($src, $app->lang_resource('zh_CN'))) {
$file = $app->lang_url . '/zh_CN/' . $src;
} else {
return '';
}
if (isset($params['pdir'])) {
unset($params['pdir']);
}
if (isset($params['src'])) {
unset($params['src']);
}
if (isset($params['app'])) {
unset($params['app']);
}
$params = count($params) ? $params + $default : $default;
foreach ($params as $k => $v) {
$ext .= sprintf('%s="%s" ', $k, $v);
}
$version = $this->getVer($debug);
return sprintf('<link href="%s" %s/>', $file . $version, $ext);
}
示例10: lang_css
function lang_css($params)
{
if (empty($params['app'])) {
throw new \InvalidArgumentException('lang script tag missing app argument. detail:' . $params['src']);
}
$app = app::get($params['app']);
$default = array('rel' => 'stylesheet', 'media' => 'screen, projection');
$lang = kernel::get_lang();
$debug = config::get('app.debug', false);
if ($params['pdir'] && !$debug) {
$pdir = $params['pdir'];
} else {
$pdir = 'css';
}
$src = $pdir . '/' . $params['src'];
if (is_array($app->lang_resource($lang)) && in_array($src, $app->lang_resource($lang))) {
$file = $app->lang_url . '/' . $lang . '/' . $src;
} elseif (is_array($app->lang_resource('zh_CN')) && in_array($src, $app->lang_resource('zh_CN'))) {
$file = $app->lang_url . '/zh_CN/' . $src;
} else {
return '';
}
if (isset($params['pdir'])) {
unset($params['pdir']);
}
if (isset($params['src'])) {
unset($params['src']);
}
if (isset($params['app'])) {
unset($params['app']);
}
$params = count($params) ? $params + $default : $default;
foreach ($params as $k => $v) {
$ext .= sprintf('%s="%s" ', $k, $v);
}
$version = $this->getVer($debug);
return sprintf('<link href="%s" %s/>', $file . $version, $ext);
}