当前位置: 首页>>代码示例>>PHP>>正文


PHP Locales::getInstance方法代码示例

本文整理汇总了PHP中Locales::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Locales::getInstance方法的具体用法?PHP Locales::getInstance怎么用?PHP Locales::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Locales的用法示例。


在下文中一共展示了Locales::getInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: drawSetLang

function drawSetLang($currentLang = "ko", $curPosition = 'Norm')
{
    $locale = Locales::getInstance();
    if ($locale->setDirectory(ROOT . '/resources/locale/setup')) {
        $availableLanguages = $locale->getSupportedLocales();
    } else {
        return false;
    }
    ?>
		Select Default Language :
		<select name="Lang" id = "Lang" onchange= "current();" >
<?php 
    foreach ($availableLanguages as $key => $value) {
        print '			<option value="' . $key . '" ' . ($key == $currentLang ? ' selected="selected" ' : '') . '>' . $value . '</option>' . CRLF;
    }
    ?>
		</select>
<?php 
    return true;
}
开发者ID:hoksi,项目名称:Textcube,代码行数:20,代码来源:setup.php

示例2: getCurrentSetting

 $context->setProperty('plugin.uri.access', $pluginAccessURL);
 $context->setProperty('plugin.uri.menu', $pluginMenuURL);
 $context->setProperty('plugin.uri.handler', $pluginHandlerURL);
 $context->setProperty('plugin.uri.self', $pluginSelfURL);
 $context->setProperty('plugin.parameter.access', $pluginAccessParam);
 $context->setProperty('plugin.parameter.self', $pluginSelfParam);
 $context->setProperty('plugin.uri', $context->getProperty('service.path') . "/plugins/{$plugin}");
 $context->setProperty('plugin.path', ROOT . "/plugins/{$plugin}");
 $context->setProperty('plugin.name', $plugin);
 $pluginURL = $context->getProperty('plugin.uri');
 $pluginPath = $context->getProperty('plugin.path');
 $pluginName = $context->getProperty('plugin.name');
 // Loading locale resource
 $languageDomain = null;
 if (is_dir($pluginPath . '/locale/')) {
     $locale = Locales::getInstance();
     $languageDomain = $locale->domain;
     if (file_exists($pluginPath . '/locale/' . $locale->defaultLanguage . '.php')) {
         $locale->setDirectory($pluginPath . '/locale');
         $locale->set($locale->defaultLanguage, $pluginName);
         $locale->domain = $pluginName;
     }
 }
 include_once ROOT . "/plugins/{$plugin}/index.php";
 if (function_exists($handler)) {
     if (!empty($configMappings[$plugin]['config'])) {
         $configVal = getCurrentSetting($plugin);
         $context->setProperty('plugin.config', Setting::fetchConfigVal($configVal));
     } else {
         $configVal = '';
         $context->setProperty('plugin.config', array());
开发者ID:Avantians,项目名称:Textcube,代码行数:31,代码来源:index.php

示例3: _text

function _text($t)
{
    $locale = Locales::getInstance();
    if (isset($locale->resource[$locale->domain]) && isset($locale->resource[$locale->domain][$t])) {
        return $locale->resource[$locale->domain][$t];
    } else {
        return $t;
    }
}
开发者ID:Avantians,项目名称:Textcube,代码行数:9,代码来源:Locales.php

示例4: handleDataSet

function handleDataSet($plugin, $DATA)
{
    global $configMappings, $activePlugins, $service, $pluginURL, $pluginPath, $pluginName, $configMapping, $configVal;
    $context = Model_Context::getInstance();
    $xmls = new XMLStruct();
    if (!$xmls->open($DATA)) {
        unset($xmls);
        return array('error' => '3', 'customError' => '');
    }
    unset($xmls);
    if (!in_array($plugin, $activePlugins)) {
        return array('error' => '9', 'customError' => _f('%1 : 플러그인이 활성화되어 있지 않아 설정을 저장하지 못했습니다.', $plugin));
    }
    $reSetting = true;
    if (!empty($configMappings[$plugin]['dataValHandler'])) {
        $context->setProperty('plugin.uri', $context->getProperty('service.path') . "/plugins/{$plugin}");
        $context->setProperty('plugin.path', ROOT . "/plugins/{$plugin}");
        $context->setProperty('plugin.name', $plugin);
        $pluginURL = $context->getProperty('plugin.uri');
        // Legacy plugin support.
        $pluginPath = $context->getProperty('plugin.path');
        $pluginName = $context->getProperty('plugin.name');
        include_once ROOT . "/plugins/{$plugin}/index.php";
        if (function_exists($configMappings[$plugin]['dataValHandler'])) {
            if (!empty($configMappings[$plugin]['config'])) {
                $configVal = getCurrentSetting($plugin);
                $context->setProperty('plugin.config', Setting::fetchConfigVal($configVal));
            } else {
                $configVal = '';
                $context->setProperty('plugin.config', array());
            }
            // Loading locale resource
            $languageDomain = null;
            if (is_dir($pluginPath . '/locale/')) {
                $locale = Locales::getInstance();
                $languageDomain = $locale->domain;
                if (file_exists($pluginPath . '/locale/' . $locale->defaultLanguage . '.php')) {
                    $locale->setDirectory($pluginPath . '/locale');
                    $locale->set($locale->defaultLanguage, $pluginName);
                    $locale->domain = $pluginName;
                }
            }
            $reSetting = call_user_func($configMappings[$plugin]['dataValHandler'], serialize(fetchConfigXML($DATA)));
            $pluginURL = $pluginPath = $pluginName = "";
            $context->unsetProperty('plugin.uri');
            $context->unsetProperty('plugin.path');
            $context->unsetProperty('plugin.name');
            $context->unsetProperty('plugin.config', array());
            if (!is_null($languageDomain)) {
                $locale->domain = $languageDomain;
            }
        }
        if (true !== $reSetting) {
            return array('error' => '9', 'customError' => $reSetting);
        }
    }
    $result = updatePluginConfig($plugin, $DATA);
    return array('error' => $result, 'customError' => '');
}
开发者ID:webhacking,项目名称:Textcube,代码行数:59,代码来源:plugin.php

示例5: explode

 function &selectNode($path, $lang = null)
 {
     $path = explode('/', $path);
     if (array_shift($path) != '') {
         $null = null;
         return $null;
     }
     $cursor =& $this->struct;
     while (is_array($cursor) && ($step = array_shift($path))) {
         $step = $this->expandNS($step);
         if (!preg_match('/^([^[]+)(\\[(\\d+|lang\\(\\))\\])?$/', $step, $matches)) {
             $null = null;
             return $null;
         }
         $name = $matches[1];
         if (!isset($cursor[$name][0])) {
             $null = null;
             return $null;
         }
         if (count($matches) != 4) {
             // Node name only.
             if (isset($cursor[$name][0])) {
                 $cursor =& $cursor[$name][0];
             } else {
                 $null = null;
                 return $null;
             }
         } else {
             if ($matches[3] != 'lang()') {
                 // Position.
                 /* see http://dev.textcube.org/ticket/430 */
                 $index = $matches[3];
                 $index -= $this->baseindex;
                 if (isset($cursor[$name][$index])) {
                     $cursor =& $cursor[$name][$index];
                 } else {
                     $null = null;
                     return $null;
                 }
             } else {
                 // lang() expression.
                 for ($i = 0; $i < count($cursor[$name]); $i++) {
                     if (isset($cursor[$name][$i]['.attributes']['xml:lang'])) {
                         $lang = $cursor[$name][$i]['.attributes']['xml:lang'];
                     } else {
                         $lang = "";
                     }
                     $locale = Locales::getInstance();
                     switch ($locale->match($lang)) {
                         case 3:
                             $cursor =& $cursor[$name][$i];
                             return $cursor;
                         case 2:
                             $secondBest =& $cursor[$name][$i];
                             break;
                         case 1:
                             $thirdBest =& $cursor[$name][$i];
                             break;
                         case 0:
                             if (!isset($thirdBest)) {
                                 $thirdBest =& $cursor[$name][$i];
                             }
                             break;
                     }
                 }
                 if (isset($secondBest)) {
                     $cursor =& $secondBest;
                 } else {
                     if (isset($thirdBest)) {
                         $cursor =& $thirdBest;
                     } else {
                         $null = null;
                         return $null;
                     }
                 }
             }
         }
     }
     return $cursor;
 }
开发者ID:ni5am,项目名称:Textcube,代码行数:80,代码来源:10-CoreClasses.php


注:本文中的Locales::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。