Returns the published documents in the current language.

        :param request: A Request instance.
971033
def published(self, request=None):
        
        language = getattr(request, 'LANGUAGE_CODE', get_language())
        if not language:
            return self.model.objects.none()

        qs = self.get_queryset()
        qs = qs.filter(
            translations__is_published=True,
            translations__language_code=language,
        )
        # either it has no category or the one it has is published
        qs = qs.filter(
            models.Q(category__isnull=True) |
            models.Q(category__is_published=True))
        return qs
700173
def get_translation_objects(self, request, language_code, obj=None, inlines=True):
        
        if obj is not None:
            # A single model can hold multiple TranslatedFieldsModel objects.
            # Return them all.
            for translations_model in obj._parler_meta.get_all_models():
                try:
                    translation = translations_model.objects.get(master=obj, language_code=language_code)
                except translations_model.DoesNotExist:
                    continue
                yield [translation]

        if inlines:
            for inline, qs in self._get_inline_translations(request, language_code, obj=obj):
                yield qs
708147
def determine_content(request):
        

        if not request.META.get('CONTENT_LENGTH', None) \
           and not request.META.get('TRANSFER_ENCODING', None):
            return None

        return request.META.get('CONTENT_TYPE', None)
979667
def get_object(self, request, object_id, *args, **kwargs):
        
        obj = super(TranslatableAdmin, self).get_object(request, object_id, *args, **kwargs)

        if obj is not None and self._has_translatable_model():  # Allow fallback to regular models.
            obj.set_current_language(self._language(request, obj), initialize=True)

        return obj
1318468
def list(self, request, *args, **kwargs):
        """"""
        search_kwargs = {"published": False}

        query_params = get_query_params(self.request)

        for field_name in ("status"):
            if field_name in query_params:
                search_kwargs[field_name] = query_params.get(field_name)

        if "search" in query_params:
            search_kwargs["query"] = query_params.get("search")

        # active/closed are semantics of the Poll model
        # active is analagous to 'published' in Content
        # closed is in relation to the end_date of a Poll
        if "active" in query_params:
            del search_kwargs["published"]
            search_kwargs["active"] = True

        if "closed" in query_params:
            del search_kwargs["published"]
            search_kwargs["closed"] = True

        queryset = self.model.search_objects.search(**search_kwargs)

        page = self.paginate_queryset(queryset)
        if page is not None:
            serializer = self.get_serializer(page, many=True)
            return self.get_paginated_response(serializer.data)

        serializer = self.get_serializer(queryset, many=True)
        return Response(serializer.data)
1200581
def get_queryset(self, request):
        
        self.request = request

        qs = super(PublishingFluentPagesParentAdminMixin, self) \
            .get_queryset(request)
        qs = qs.filter(status=UrlNode.DRAFT)
        return qs
1281136
def get_languages(self):
        
        if self._languages:
            return self._languages
        self._languages = cache.get(self.PAGE_LANGUAGES_KEY % (self.pk))
        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 = sorted(set(languages))
        cache.set(self.PAGE_LANGUAGES_KEY % (self.pk), languages)
        self._languages = languages
        return languages
476449
def get_form_language(self, request, obj=None):
        
        if obj is not None:
            return obj.get_current_language()
        else:
            return self._language(request)
522139
def _searchable_form(self) -> 'Language':
        
        if self._searchable is not None:
            return self._searchable

        self._searchable = self._filter_attributes(
            {'language', 'script', 'region'}
        ).simplify_script().prefer_macrolanguage()
        return self._searchable
464961
def translate_request(request):
    
    message = request._message
    payload = request._payload

    uri_parts = urlsplit(message.path)
    environ = {
        'wsgi.input': payload,
        'wsgi.errors': sys.stderr,
        'wsgi.version': (1, 0),
        'wsgi.async': True,
        'wsgi.multithread': False,
        'wsgi.multiprocess': False,
        'wsgi.run_once': False,
        'SERVER_SOFTWARE': 'aiohttp',
        'REQUEST_METHOD': message.method,
        'QUERY_STRING': uri_parts.query or '',
        'RAW_URI': message.path,
        'SERVER_PROTOCOL': 'HTTP/%s.%s' % message.version,
        'REMOTE_ADDR': '127.0.0.1',
        'REMOTE_PORT': '0',
        'SERVER_NAME': 'aiohttp',
        'SERVER_PORT': '0',
        'aiohttp.request': request
    }

    for hdr_name, hdr_value in message.headers.items():
        hdr_name = hdr_name.upper()
        if hdr_name == 'CONTENT-TYPE':
            environ['CONTENT_TYPE'] = hdr_value
            continue
        elif hdr_name == 'CONTENT-LENGTH':
            environ['CONTENT_LENGTH'] = hdr_value
            continue

        key = 'HTTP_%s' % hdr_name.replace('-', '_')
        if key in environ:
            hdr_value = '%s,%s' % (environ[key], hdr_value)

        environ[key] = hdr_value

    environ['wsgi.url_scheme'] = environ.get('HTTP_X_FORWARDED_PROTO', 'http')

    path_info = uri_parts.path

    environ['PATH_INFO'] = path_info
    environ['SCRIPT_NAME'] = ''

    return environ
450709
Locale getLocale(HandshakeRequest request) {
		if(null != request) {
			Map<String, List<String>> headers = request.getHeaders();
			if(null != headers) {
				List<String> accepts = headers.get(HttpHeaders.ACCEPT_LANGUAGE);
				logger.debug("Get accept-language from client headers : {}", accepts);
				if (null != accepts) {
					for (String accept : accepts) {
						try {
							return localeExtractor.extractFromAccept(accept);
						} catch (LocaleNotFoundException ex) {
						}
					}
				}
			}
		}
		return Locale.US;
	}
204273
def get_language_tabs(request, current_language, available_languages, css_class=None):
    
    tabs = TabsList(css_class=css_class)
    get = request.GET.copy()  # QueryDict object
    tab_languages = []

    site_id = getattr(settings, 'SITE_ID', None)
    for lang_dict in appsettings.PARLER_LANGUAGES.get(site_id, ()):
        code = lang_dict['code']
        title = get_language_title(code)
        get['language'] = code
        url = '?{0}'.format(get.urlencode())

        if code == current_language:
            status = 'current'
        elif code in available_languages:
            status = 'available'
        else:
            status = 'empty'

        tabs.append((url, title, code, status))
        tab_languages.append(code)

    # Additional stale translations in the database?
    if appsettings.PARLER_SHOW_EXCLUDED_LANGUAGE_TABS:
        for code in available_languages:
            if code not in tab_languages:
                get['language'] = code
                url = '?{0}'.format(get.urlencode())

                if code == current_language:
                    status = 'current'
                else:
                    status = 'available'

                tabs.append((url, get_language_title(code), code, status))

    tabs.current_is_translated = current_language in available_languages
    tabs.allow_deletion = len(available_languages) > 1
    return tabs
886376
def runGetInfo(self, request):
        
        return protocol.toJson(protocol.GetInfoResponse(
            protocol_version=protocol.version))
761461
def kem(request):
	
	keyword = request.GET['keyword']
	lang = request.GET['lang']
	ontology = 'ontology' if 'ontology' in request.GET and bool(json.loads(request.GET['ontology'].lower())) else 'origin'
	result = multilanguage_model[lang][ontology].most_similar(keyword, int(request.GET['num']) if 'num' in request.GET else 10)
	return JsonResponse(result, safe=False)
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
984452
def runSearchReads(self, request):
        
        return self.runSearchRequest(
            request, protocol.SearchReadsRequest,
            protocol.SearchReadsResponse,
            self.readsGenerator)
509892
def get_language(self, language_id):
        

        raw_response = requests_util.run_request('get', self.API_BASE_URL + '/languages/%d' % language_id,
                                                 headers=self.__get_header_with_auth())

        return self.parse_raw_response(raw_response)