本文整理汇总了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;
}
示例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';
}
示例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';
}
示例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;
}
示例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';
}