gets the language set in the query string
169404
function getLanguageFromQueryString() {
    if (location.search.length >= 1) {
      var language = parseURL(location.search).language
      if (language) {
        return language;
      } else if (jQuery.inArray(location.search.substr(1), languages) != -1) {
        return location.search.substr(1);
      }
    }

    return false;
  }
1130827
def get_queryset(self, request):
        
        qs = super(BaseTranslatableAdmin, self).get_queryset(request)

        if self._has_translatable_model():
            if not isinstance(qs, TranslatableQuerySet):
                raise ImproperlyConfigured("{0} class does not inherit from TranslatableQuerySet".format(qs.__class__.__name__))

            # Apply a consistent language to all objects.
            qs_language = self.get_queryset_language(request)
            if qs_language:
                qs = qs.language(qs_language)

        return qs
593996
public static function get_content_languages()
    {
        $table = Versioned::current_stage() == 'Live' ? 'SiteTree_Live' : 'SiteTree';

        if (class_exists('SQLSelect')) {
            $query = new SQLSelect("Distinct \"Locale\"", "\"$table\"");
        } else {
            // SS 3.1 compat
            $query = new SQLQuery("Distinct \"Locale\"", array("\"$table\""));
        }

        $query = $query->setGroupBy('"Locale"');
        $dbLangs = $query->execute()->column();

        $langlist = array_merge((array)Translatable::default_locale(), (array)$dbLangs);
        $returnMap = array();
        $allCodes = array_merge(
            Config::inst()->get('i18n', 'all_locales'),
            Config::inst()->get('i18n', 'common_locales')
        );
        foreach ($langlist as $langCode) {
            if ($langCode && isset($allCodes[$langCode])) {
                if (is_array($allCodes[$langCode])) {
                    $returnMap[$langCode] = $allCodes[$langCode]['name'];
                } else {
                    $returnMap[$langCode] = $allCodes[$langCode];
                }
            }
        }
        return $returnMap;
    }
1040334
public function filterByLanguagePresets($queryResult, array $presets) {
    $result = $queryResult;

    if (!empty($presets)) {
      $sysLanguageUid = $this->languageService->getSysLanguageUid();
      $preset         = intval($presets[$sysLanguageUid]);

      if (isset($preset)) {
        $result = [];

        foreach ($queryResult as $object) {
          $uid = $object->getSysLanguageUid();

          if (isset($uid) && $uid == $preset) {
            $result[] = $object;
          }
        }
      }
    }

    return $result;
  }
1120139
def get_all_languages(self, sort='code'):
    
    langs = list(self.culturecode_set.all().as_languages())
    langs.extend(self.language_set.exclude(iso_639_1__in=[x.iso_639_1 for x in langs]))
    if sort in ['name_en', 'name_native']:
        langs.sort(key=lambda x: getattr(x, sort))
    elif sort == 'code':
        codes = self.languages.split(',')

        def code_sort(x):
            return codes.index(x.sort_code)

        langs.sort(key=code_sort)
    else:
        raise ValueError(
            'Invalid code option %s.  Valid options are: code, name_en, name_native' % sort)
    return langs
722822
public function QueryLanguage()
    {
        $this->lexer->moveNext();

        switch ($this->lexer->lookahead['type']) {
            case Lexer::T_SELECT:
                $statement = $this->SelectStatement();
                break;

            case Lexer::T_UPDATE:
                $statement = $this->UpdateStatement();
                break;

            case Lexer::T_DELETE:
                $statement = $this->DeleteStatement();
                break;

            default:
                $this->syntaxError('SELECT, UPDATE or DELETE');
                break;
        }

        // Check for end of string
        if ($this->lexer->lookahead !== null) {
            $this->syntaxError('end of string');
        }

        return $statement;
    }
657720
def getlanguages(self, event):
        """"""

        self.log('Client requests all languages.', lvl=verbose)
        result = {
            'component': 'hfos.ui.clientmanager',
            'action': 'getlanguages',
            'data': language_token_to_name(all_languages())
        }
        self.fireEvent(send(event.client.uuid, result))
29876
public function getQueryString() {
        // The variable $_SERVER['QUERY_STRING'] is set by the server and can differ from the transmitted query string.
        // It might hold additional parameters added by the server or it might be empty (e.g. on a mis-configured nginx).

        if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING'])) {
            $query = $_SERVER['QUERY_STRING'];
        }
        else {
            $query = strRightFrom($_SERVER['REQUEST_URI'], '?');
        }
        return $query;
    }
1256588
public static function getLangFromRequest()
    {
        if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            return '';
        }

        $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
        foreach ($languages as $bl) {
            if (preg_match('/^([a-zA-Z]{2,3})(?:[-_]([a-zA-Z]{2,3}))?(;q=[0-9]\\.[0-9])?$/', $bl, $match)) {
                $lang = strtolower($match[1]);

                return $lang;
            }
        }

        return '';
    }
1113328
function guessLanguage(request){
	//console.log("guessLanguage");
    if(typeof request === 'object'){
        var language_header = request.headers['accept-language'],
        languages = [];
        regions = [];
        request.languages = [currentLocale];
		/*
		for (x in request.languages)
		{
			console.log(request.languages[x] + x);
		}
		*/
        request.regions = [currentLocale];
        request.language = currentLocale;
        request.region = currentLocale;

        if (language_header) {
            language_header.split(',').forEach(function(l) {
                header = l.split(';', 1)[0];
                lr = header.split('-', 2);
                if (lr[0]) {
                    languages.push(lr[0].toLowerCase());
                }
                if (lr[1]) {
                    regions.push(lr[1].toLowerCase());
                }
            });

            if (languages.length > 0) {
                request.languages = languages;
                request.language = languages[0];
            }

            if (regions.length > 0) {
                request.regions = regions;
                request.region = regions[0];
            }
        }
        i18n.setLocale(request.language);
    }
}
382373
def _language(self, item):
        """"""

        response = item['spider_response'].body
        root = html.fromstring(response)

        # Check for lang-attributes
        lang = root.get('lang')

        if lang is None:
            lang = root.get('xml:lang')

        # Check for general meta tags
        if lang is None:
            meta = root.cssselect('meta[name="language"]')
            if len(meta) > 0:
                lang = meta[0].get('content')

        # Check for open graph tags
        if lang is None:
            meta = root.cssselect('meta[property="og:locale"]')
            if len(meta) > 0:
                lang = meta[0].get('content')

        # Look for <article> elements and inspect the one with the largest payload with langdetect
        if lang is None:
            article_list = []
            for article in root.xpath('//article'):
                article_list.append(re.sub(r'\s+', ' ', article.text_content().strip()))
                if len(article_list) > 0:
                    lang = detect(max(article_list))

        # Analyze the whole body with langdetect
        if lang is None:
            try:
                lang = detect(root.text_content().strip())
            except LangDetectException:
                pass

        # Try to normalize output
        if lang is not None:
            # First search for suitable locale in the original output
            matches = self.langcode_pattern.search(lang)
            if matches is not None:
                lang = matches.group(0)
            else:
                # If no match was found, normalize the original output and search again
                normalized = locale.normalize(re.split(r'\s|;|,', lang.strip())[0])
                matches = self.langcode_pattern.search(normalized)
                if matches is not None:
                    lang = matches.group(0)

        return lang
1118364
def get_languages(self):
        
        if self._languages:
            return self._languages
        self._languages = cache.get(self.PAGE_LANGUAGES_KEY % (self.id))
        if self._languages is not None:
            return self._languages

        languages = [c['language'] for
                            c in Content.objects.filter(page=self,
                            type="slug").values('language')]
        # remove duplicates
        languages = list(set(languages))
        languages.sort()
        cache.set(self.PAGE_LANGUAGES_KEY % (self.id), languages)
        self._languages = languages
        return languages
535972
function fetchLanguage ( url, language ) {
	const part = url.split('/'); part.pop();
	return got(normalizeUrl(`${API_URL}/${path.join(part.join('/'))}/${language}`));
}
757924
def get_users_indexed_by_lang():
        
        result = {}
        users = TransUser.objects.filter(active=True).select_related('user')
        for user in users:
            for lang in user.languages.all():
                if lang.code not in result:
                    result[lang.code] = set()
                result[lang.code].add(user)
        return result
1055880
def getLanguage(self, body, ):
        

        resourcePath = '/text/detect_language'
        method = 'POST'

        queryParams = {}
        headerParams = {'Accept': 'Application/json', 'Content-Type': 'application/json'}
        postData = None

        postData = body
        response = self.apiClient._callAPI(resourcePath, method, queryParams, postData, headerParams)
        return language_rest.LanguageRest(**response.json())
205020
public function get_user_language()
    {
        if (is_object($this->user)) {
            return $this->user->language;
        }
        else if (isset($_SESSION['language'])) {
            return $_SESSION['language'];
        }
    }
1309322
def get_first_lang():
    
    request_lang = request.headers.get('Accept-Language').split(',')
    if request_lang:
        lang = locale.normalize(request_lang[0]).split('.')[0]
    else:
        lang = False
    return lang