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


PHP OC_L10N::language方法代码示例

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


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

示例1: findLanguage

 /**
  * find the best language
  * @param string $app
  * @return string language
  *
  * If nothing works it returns 'en'
  */
 public static function findLanguage($app = null)
 {
     if (self::$language != '') {
         return self::$language;
     }
     $config = \OC::$server->getConfig();
     $userId = \OC_User::getUser();
     if ($userId && $config->getUserValue($userId, 'core', 'lang')) {
         $lang = $config->getUserValue($userId, 'core', 'lang');
         self::$language = $lang;
         if (self::languageExists($app, $lang)) {
             return $lang;
         }
     }
     $default_language = $config->getSystemValue('default_language', false);
     if ($default_language !== false) {
         return $default_language;
     }
     $lang = self::setLanguageFromRequest();
     if ($userId && !$config->getUserValue($userId, 'core', 'lang')) {
         $config->setUserValue($userId, 'core', 'lang', $lang);
     }
     return $lang;
 }
开发者ID:slapia,项目名称:core,代码行数:31,代码来源:l10n.php

示例2: findLanguage

 /**
  * @brief find the best language
  * @param $app Array or string, details below
  * @returns language
  *
  * If $app is an array, ownCloud assumes that these are the available
  * languages. Otherwise ownCloud tries to find the files in the l10n
  * folder.
  *
  * If nothing works it returns 'en'
  */
 public static function findLanguage($app = null)
 {
     if (!is_array($app) && self::$language != '') {
         return self::$language;
     }
     if (OC_User::getUser() && OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang')) {
         $lang = OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang');
         self::$language = $lang;
         if (is_array($app)) {
             $available = $app;
             $lang_exists = array_search($lang, $available) !== false;
         } else {
             $lang_exists = self::languageExists($app, $lang);
         }
         if ($lang_exists) {
             return $lang;
         }
     }
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $accepted_languages = preg_split('/,\\s*/', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
         if (is_array($app)) {
             $available = $app;
         } else {
             $available = self::findAvailableLanguages($app);
         }
         foreach ($accepted_languages as $i) {
             $temp = explode(';', $i);
             $temp[0] = str_replace('-', '_', $temp[0]);
             if (($key = array_search($temp[0], $available)) !== false) {
                 return $available[$key];
             }
             foreach ($available as $l) {
                 if ($temp[0] == substr($l, 0, 2)) {
                     return $l;
                 }
             }
         }
     }
     // Last try: English
     return 'en';
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:52,代码来源:l10n.php

示例3: findLanguage

 /**
  * @brief find the best language
  * @param $app Array or string, details below
  * @returns language
  *
  * If $app is an array, ownCloud assumes that these are the available
  * languages. Otherwise ownCloud tries to find the files in the l10n 
  * folder.
  *
  * If nothing works it returns 'en'
  */
 public static function findLanguage($app = null)
 {
     if (!is_array($app) && self::$language != '') {
         return self::$language;
     }
     $available = array();
     if (is_array($app)) {
         $available = $app;
     } else {
         $available = self::findAvailableLanguages($app);
     }
     if (OC_User::getUser() && OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang')) {
         $lang = OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang');
         self::$language = $lang;
         if (array_search($lang, $available) !== false) {
             return $lang;
         }
     }
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $accepted_languages = preg_split('/,\\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         foreach ($accepted_languages as $i) {
             $temp = explode(';', $i);
             if (array_search($temp[0], $available) !== false) {
                 return $temp[0];
             }
         }
     }
     // Last try: English
     return 'en';
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:41,代码来源:l10n.php

示例4: findLanguage

 /**
  * find the best language
  * @param array|string $app details below
  * @return string language
  *
  * If $app is an array, ownCloud assumes that these are the available
  * languages. Otherwise ownCloud tries to find the files in the l10n
  * folder.
  *
  * If nothing works it returns 'en'
  */
 public static function findLanguage($app = null)
 {
     if (!is_array($app) && self::$language != '') {
         return self::$language;
     }
     $config = \OC::$server->getConfig();
     $userId = \OC_User::getUser();
     if ($userId && $config->getUserValue($userId, 'core', 'lang')) {
         $lang = $config->getUserValue($userId, 'core', 'lang');
         self::$language = $lang;
         if (is_array($app)) {
             $available = $app;
             $lang_exists = array_search($lang, $available) !== false;
         } else {
             $lang_exists = self::languageExists($app, $lang);
         }
         if ($lang_exists) {
             return $lang;
         }
     }
     $default_language = $config->getSystemValue('default_language', false);
     if ($default_language !== false) {
         return $default_language;
     }
     $lang = self::setLanguageFromRequest($app);
     if ($userId && !$config->getUserValue($userId, 'core', 'lang')) {
         $config->setUserValue($userId, 'core', 'lang', $lang);
     }
     return $lang;
 }
开发者ID:Badbits,项目名称:core,代码行数:41,代码来源:l10n.php

示例5: findLanguage

 /**
  * find the best language
  * @param array|string $app details below
  * @return string language
  *
  * If $app is an array, ownCloud assumes that these are the available
  * languages. Otherwise ownCloud tries to find the files in the l10n
  * folder.
  *
  * If nothing works it returns 'en'
  */
 public static function findLanguage($app = null)
 {
     if (!is_array($app) && self::$language != '') {
         return self::$language;
     }
     if (OC_User::getUser() && \OC::$server->getConfig()->getUserValue(OC_User::getUser(), 'core', 'lang')) {
         $lang = \OC::$server->getConfig()->getUserValue(OC_User::getUser(), 'core', 'lang');
         self::$language = $lang;
         if (is_array($app)) {
             $available = $app;
             $lang_exists = array_search($lang, $available) !== false;
         } else {
             $lang_exists = self::languageExists($app, $lang);
         }
         if ($lang_exists) {
             return $lang;
         }
     }
     $default_language = \OC::$server->getConfig()->getSystemValue('default_language', false);
     if ($default_language !== false) {
         return $default_language;
     }
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         if (is_array($app)) {
             $available = $app;
         } else {
             $available = self::findAvailableLanguages($app);
         }
         // E.g. make sure that 'de' is before 'de_DE'.
         sort($available);
         $preferences = preg_split('/,\\s*/', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
         foreach ($preferences as $preference) {
             list($preferred_language) = explode(';', $preference);
             $preferred_language = str_replace('-', '_', $preferred_language);
             foreach ($available as $available_language) {
                 if ($preferred_language === strtolower($available_language)) {
                     if (is_null($app)) {
                         self::$language = $available_language;
                     }
                     return $available_language;
                 }
             }
             foreach ($available as $available_language) {
                 if (substr($preferred_language, 0, 2) === $available_language) {
                     if (is_null($app)) {
                         self::$language = $available_language;
                     }
                     return $available_language;
                 }
             }
         }
     }
     // Last try: English
     return 'en';
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:66,代码来源:l10n.php


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