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


PHP Common::getBrowserLanguage方法代码示例

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


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

示例1: getLocation

 /**
  * Guesses a visitor's location using a visitor's browser language.
  *
  * @param array $info Contains 'ip' & 'lang' keys.
  * @return array Contains the guessed country code mapped to LocationProvider::COUNTRY_CODE_KEY.
  */
 public function getLocation($info)
 {
     $enableLanguageToCountryGuess = Config::getInstance()->Tracker['enable_language_to_country_guess'];
     if (empty($info['lang'])) {
         $info['lang'] = Common::getBrowserLanguage();
     }
     $country = Common::getCountry($info['lang'], $enableLanguageToCountryGuess, $info['ip']);
     $location = array(parent::COUNTRY_CODE_KEY => $country);
     $this->completeLocationResult($location);
     return $location;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:17,代码来源:Default.php

示例2: getBrowserLanguage

 /**
  * Returns the language the visitor is viewing.
  *
  * @return string browser language code, eg. "en-gb,en;q=0.5"
  */
 public function getBrowserLanguage()
 {
     return Common::getRequestVar('lang', Common::getBrowserLanguage(), 'string', $this->params);
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:9,代码来源:Request.php

示例3: getAllProviderInfo

 /**
  * Returns an array mapping provider IDs w/ information about the provider,
  * for each location provider.
  *
  * The following information is provided for each provider:
  *   'id' - The provider's unique string ID.
  *   'title' - The provider's title.
  *   'description' - A description of how the location provider works.
  *   'status' - Either self::NOT_INSTALLED, self::INSTALLED or self::BROKEN.
  *   'statusMessage' - If the status is self::BROKEN, then the message describes why.
  *   'location' - A pretty formatted location of the current IP address
  *                (IP::getIpFromHeader()).
  *
  * An example result:
  * array(
  *     'geoip_php' => array('id' => 'geoip_php',
  *                          'title' => '...',
  *                          'desc' => '...',
  *                          'status' => GeoIp::BROKEN,
  *                          'statusMessage' => '...',
  *                          'location' => '...')
  *     'geoip_serverbased' => array(...)
  * )
  *
  * @param string $newline What to separate lines with in the pretty locations.
  * @param bool $includeExtra Whether to include ISP/Org info in formatted location.
  * @return array
  */
 public static function getAllProviderInfo($newline = "\n", $includeExtra = false)
 {
     $allInfo = array();
     foreach (self::getAllProviders() as $provider) {
         $info = $provider->getInfo();
         $status = self::INSTALLED;
         $location = false;
         $statusMessage = false;
         $availableOrMessage = $provider->isAvailable();
         if ($availableOrMessage !== true) {
             $status = self::NOT_INSTALLED;
             if (is_string($availableOrMessage)) {
                 $statusMessage = $availableOrMessage;
             }
         } else {
             $workingOrError = $provider->isWorking();
             if ($workingOrError === true) {
                 $locInfo = array('ip' => IP::getIpFromHeader(), 'lang' => Common::getBrowserLanguage(), 'disable_fallbacks' => true);
                 $location = $provider->getLocation($locInfo);
                 $location = self::prettyFormatLocation($location, $newline, $includeExtra);
             } else {
                 $status = self::BROKEN;
                 $statusMessage = $workingOrError;
             }
         }
         $info['status'] = $status;
         $info['statusMessage'] = $statusMessage;
         $info['location'] = $location;
         $allInfo[$info['order']] = $info;
     }
     ksort($allInfo);
     $result = array();
     foreach ($allInfo as $info) {
         $result[$info['id']] = $info;
     }
     return $result;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:65,代码来源:LocationProvider.php

示例4: testGetBrowserLanguage

 /**
  * @dataProvider getBrowserLanguageData
  * @group Core
  */
 public function testGetBrowserLanguage($useragent, $browserLanguage)
 {
     $res = Common::getBrowserLanguage($useragent);
     $this->assertEquals($browserLanguage, $res);
 }
开发者ID:cemo,项目名称:piwik,代码行数:9,代码来源:CommonTest.php

示例5: getLanguageCodeForCurrentUser

 /**
  * @return string Two letters language code, eg. "fr"
  */
 public static function getLanguageCodeForCurrentUser()
 {
     $languageCode = self::getLanguageFromPreferences();
     if (!API::getInstance()->isLanguageAvailable($languageCode)) {
         $languageCode = Common::extractLanguageCodeFromBrowserLanguage(Common::getBrowserLanguage(), API::getInstance()->getAvailableLanguages());
     }
     if (!API::getInstance()->isLanguageAvailable($languageCode)) {
         $languageCode = Translate::getLanguageDefault();
     }
     return $languageCode;
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:14,代码来源:LanguagesManager.php

示例6: getLocationUsingProvider

 /**
  * Echo's a pretty formatted location using a specific LocationProvider.
  *
  * Input:
  *   The 'id' query parameter must be set to the ID of the LocationProvider to use.
  *
  * Output:
  *   The pretty formatted location that was obtained. Will be HTML.
  */
 public function getLocationUsingProvider()
 {
     $providerId = Common::getRequestVar('id');
     $provider = LocationProvider::getProviderById($providerId);
     if (empty($provider)) {
         throw new Exception("Invalid provider ID: '{$providerId}'.");
     }
     $location = $provider->getLocation(array('ip' => IP::getIpFromHeader(), 'lang' => Common::getBrowserLanguage(), 'disable_fallbacks' => true));
     $location = LocationProvider::prettyFormatLocation($location, $newline = '<br/>', $includeExtra = true);
     return $location;
 }
开发者ID:piwik,项目名称:piwik,代码行数:20,代码来源:Controller.php


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