Return the current language for the currently displayed object fields.
4129
def get_form_language(self, request, obj=None):
        
        if self._has_translatable_parent_model():
            return super(TranslatableInlineModelAdmin, self).get_form_language(request, obj=obj)
        else:
            # Follow the ?language parameter
            return self._language(request)
527718
def get_localized_field_name(context, field):
    """"""
    attrs = [
             translation.get_language(), 
             translation.get_language()[:2], 
             settings.LANGUAGE_CODE
            ]
            
    def predicate(x):
        field_name = get_real_fieldname(field, x)
        if hasattr(context, field_name):
            return field_name
        return None

    return first_match(predicate, attrs)
270562
def get_language_parameter(request, query_language_key='language', object=None, default=None):
    
    # This is the same logic as the django-admin uses.
    # The only difference is the origin of the request parameter.
    if not is_multilingual_project():
        # By default, the objects are stored in a single static language.
        # This makes the transition to multilingual easier as well.
        # The default language can operate as fallback language too.
        return default or appsettings.PARLER_LANGUAGES.get_default_language()
    else:
        # In multilingual mode, take the provided language of the request.
        code = request.GET.get(query_language_key)

        if not code:
            # forms: show first tab by default
            code = default or appsettings.PARLER_LANGUAGES.get_first_language()

        return normalize_language_code(code)
425067
def get_translated_attribute(instance, attr):
	
	
	# If its class has no translatable fields, returns attribute
	try:
		if not hasattr(instance._meta, "translatable_fields") or len(getattr(instance._meta,"translatable_fields"))==0:
			return getattr(instance, attr)
	except AttributeError:
		return instance
	
	# Translatable fields of this instance
	translatable_fields = instance._meta.translatable_fields

	# Current language
	cur_language = get_language()
	lang = cur_language.title().lower()

	# If current language is default language, returns attribute
	if lang == settings.LANGUAGE_CODE:
		return getattr(instance, attr)
	
	# Otherwise, if a translation is NOT needed for attr atribute, get attribute
	if not attr in translatable_fields:
		return getattr(instance, attr)

	# Gets field translations of this instance and return the translated attribute
	field_translation = _get_fieldtranslations(instance, field=attr, lang=lang)
	if field_translation:
		if not field_translation.is_fuzzy:
			return field_translation.translation
	return getattr(instance, attr)
85620
def current(self, fields=None):
        """"""
        if fields is None:
            deferred_fields = self.deferred_fields
            if deferred_fields:
                fields = [
                    field for field in self.fields
                    if field not in deferred_fields
                ]
            else:
                fields = self.fields

        return dict((f, self.get_field_value(f)) for f in fields)
106001
def get_value(self, context, obj, field_name):
        
        try:
            language = get_language()
            value = self.get_translated_value(obj, field_name, language)
            if value:
                return value
            if self.FALLBACK:
                for lang, lang_name in settings.LANGUAGES:
                    if lang == language:
                        # already tried this one...
                        continue
                    value = self.get_translated_value(obj, field_name, lang)
                    if value:
                        return value
            untranslated = getattr(obj, field_name)
            if self._is_truthy(untranslated):
                return untranslated
            else:
                return self.EMPTY_VALUE
        except Exception:
            if settings.TEMPLATE_DEBUG:
                raise
            return self.EMPTY_VALUE
984191
def language_obj
      @language_obj ||= begin
        lookup = self.language_code || self.language_str
        LanguageList::LanguageInfo.find( lookup.dup ) if lookup
      end
    end
1071634
def lang(self):
        
        return str(self.graph.value(self.asNode(), DC.language))
1064024
def _get_fieldtranslations(instance, field=None, lang=None):
	

	# Basic filtering: filter translations by module, model an object_id
	_filter = {"module": instance.__module__, "model": instance.__class__.__name__, "object_id": instance.id}

	if lang:
		_filter["lang"] = lang

	# If we specify a field we get ONE translation (this field translation)
	if field:
		_filter["field"] = field
		try:
			return FieldTranslation.objects.get(**_filter)
		except FieldTranslation.DoesNotExist:
			return False

	# Otherwise, we get all translations
	return FieldTranslation.objects.filter(**_filter)
306757
def default_display(value, with_module=True):
    """"""
    object_type = type(value)
    try:
        name = object_type.__name__
        module = object_type.__module__
        if with_module:
            return name + ' object of ' + module + ' module'
        else:
            return name
    except:
        type_str = to_text_string(object_type)
        return type_str[1:-1]
496339
def get_parent_active_language_choices(parent_object, exclude_current=False):
    
    assert parent_object is not None, "Missing parent_object!"

    from .db import ContentItem
    qs = ContentItem.objects \
        .parent(parent_object, limit_parent_language=False) \
        .values_list('language_code', flat=True).distinct()

    languages = set(qs)

    if exclude_current:
        parent_lang = get_parent_language_code(parent_object)
        languages.discard(parent_lang)

    if parler_appsettings.PARLER_LANGUAGES and not parler_appsettings.PARLER_SHOW_EXCLUDED_LANGUAGE_TABS:
        site_id = get_parent_site_id(parent_object)
        try:
            lang_dict = parler_appsettings.PARLER_LANGUAGES[site_id]
        except KeyError:
            lang_dict = ()

        allowed_languages = set(item['code'] for item in lang_dict)
        languages &= allowed_languages

    # No multithreading issue here, object is instantiated for this user only.
    choices = [(lang, str(get_language_title(lang))) for lang in languages if lang]
    choices.sort(key=lambda tup: tup[1])
    return choices
367312
def get_fallback_languages(self):
        
        lang_dict = get_language_settings(self._current_language)
        fallbacks = [lang for lang in lang_dict['fallbacks'] if lang != self._current_language]
        return fallbacks or []
760533
def get_language():
    """"""

    global sensor_graph, statement

    if sensor_graph is not None:
        return sensor_graph

    _create_primitives()
    _create_simple_statements()
    _create_block_bnf()

    sensor_graph = ZeroOrMore(statement) + StringEnd()
    sensor_graph.ignore(comment)

    return sensor_graph
520638
def get_previous_and_current_values(self, instance):
        
        translated_field_names = self._get_translated_field_names(instance.master)
        if instance.pk:
            try:
                previous_obj = instance._meta.model.objects.get(pk=instance.pk)
                previous_values = self.get_obj_values(previous_obj, translated_field_names)
            except ObjectDoesNotExist:
                previous_values = {}
        else:
            previous_values = {}
        current_values = self.get_obj_values(instance, translated_field_names)
        return previous_values, current_values
1338897
def all_languages_column(self, object):
        
        all_languages = [code for code, __ in settings.LANGUAGES]
        return mark_safe(
            self._languages_column(
                object, all_languages, span_classes='all-languages'
            )
        )
476357
def get_language():
    
    lang = _get_language()
    if lang is None:  # Django >= 1.8
        return settings.DEFAULT_LANGUAGE
    if lang not in settings.AVAILABLE_LANGUAGES and '-' in lang:
        lang = lang.split('-')[0]
    if lang in settings.AVAILABLE_LANGUAGES:
        return lang
    return settings.DEFAULT_LANGUAGE
1315968
def get_language(self):
        
        locale = self.get_locale()
        language = locale
        if '_' in locale:
            language = locale[0:locale.index('_')]
        return language