# Path: src/slim/helpers.py
# def get_default_language():
# def get_languages():
# def get_languages_keys():
# def get_languages_dict():
# def get_language_from_request(request, default=default_language):
# def admin_change_url(app_label, module_name, object_id, extra_path='',
#                      url_title=None):
# def admin_add_url(app_label, module_name, extra_path='', url_title=None):
# def smart_resolve(var, context):
# 
# Path: src/slim/monkey_patches.py
# def monkeypatch_method(cls):
#     """
#     A decorator to add a single method to an existing class::
# 
#         @monkeypatch_method(<someclass>)
#         def <newmethod>(self, [...]):
#             pass
#     """
#     def decorator(func):
#         setattr(cls, func.__name__, func)
#         return func
#     return decorator
# 
# def monkeypatch_property(cls):
#     """
#     A decorator to add a single method as a property to an existing class::
# 
#         @monkeypatch_property(<someclass>)
#         def <newmethod>(self, [...]):
#             pass
#     """
#     def decorator(func):
#         setattr(cls, func.__name__, property(func))
#         return func
#     return decorator
# 
# Path: src/slim/settings.py
# ENABLE_MONKEY_PATCHING = get_setting('ENABLE_MONKEY_PATCHING')
# 
# Path: src/slim/translations.py
# def is_primary_language(language=None):
#     """Return true if current or passed language is the primary language.
# 
#     Return true if current or passed language is the primary language for the
#     site (the primary language is defined as the first language in
#     settings.LANGUAGES).
# 
#     :param str language:
#     :return bool:
#     """
#     if not language:
#         language = translation.get_language()
# 
#     return language == default_language


from six import PY3, text_type
from django.db import models
from django.core import exceptions
from django.utils.translation import ugettext_lazy as _
from nine import versions
from ..helpers import (
    get_languages,
    default_language,
    get_languages_keys,
    admin_change_url,
    admin_add_url
)
from ..monkey_patches import monkeypatch_method, monkeypatch_property
from ..settings import ENABLE_MONKEY_PATCHING
from ..translations import is_primary_language
    from south.modelsinspector import add_introspection_rules
                :return obj: Object of the same class as the one queried.
                """
                if is_primary_language(self.language):
                    return self
                return self.translation_of

            @monkeypatch_method(cls)
            def translation_admin(self, *args, **kwargs):
                """Get HTML with URL to the original translation if available.

                For admin use.

                :return str:
                """
                if self.translation_of:
                    if not PY3:
                        url_title = text_type(self.translation_of)
                    else:
                        url_title = self.translation_of

                    return admin_change_url(
                        self._meta.app_label,
                        self._meta.module_name,
                        self.translation_of.id,
                        url_title=url_title
                    )
                return ''
            translation_admin.allow_tags = True
            translation_admin.short_description = _('Translation of')


# Path: src/slim/helpers.py
# def get_default_language():
# def get_languages():
# def get_languages_keys():
# def get_languages_dict():
# def get_language_from_request(request, default=default_language):
# def admin_change_url(app_label, module_name, object_id, extra_path='',
#                      url_title=None):
# def admin_add_url(app_label, module_name, extra_path='', url_title=None):
# def smart_resolve(var, context):
# 
# Path: src/slim/monkey_patches.py
# def monkeypatch_method(cls):
#     """
#     A decorator to add a single method to an existing class::
# 
#         @monkeypatch_method(<someclass>)
#         def <newmethod>(self, [...]):
#             pass
#     """
#     def decorator(func):
#         setattr(cls, func.__name__, func)
#         return func
#     return decorator
# 
# def monkeypatch_property(cls):
#     """
#     A decorator to add a single method as a property to an existing class::
# 
#         @monkeypatch_property(<someclass>)
#         def <newmethod>(self, [...]):
#             pass
#     """
#     def decorator(func):
#         setattr(cls, func.__name__, property(func))
#         return func
#     return decorator
# 
# Path: src/slim/settings.py
# ENABLE_MONKEY_PATCHING = get_setting('ENABLE_MONKEY_PATCHING')
# 
# Path: src/slim/translations.py
# def is_primary_language(language=None):
#     """Return true if current or passed language is the primary language.
# 
#     Return true if current or passed language is the primary language for the
#     site (the primary language is defined as the first language in
#     settings.LANGUAGES).
# 
#     :param str language:
#     :return bool:
#     """
#     if not language:
#         language = translation.get_language()
# 
#     return language == default_language


# Path: src/slim/models/fields.py
from six import PY3, text_type
from django.db import models
from django.core import exceptions
from django.utils.translation import ugettext_lazy as _
from nine import versions
from ..helpers import (
    get_languages,
    default_language,
    get_languages_keys,
    admin_change_url,
    admin_add_url
)
from ..monkey_patches import monkeypatch_method, monkeypatch_property
from ..settings import ENABLE_MONKEY_PATCHING
from ..translations import is_primary_language
    from south.modelsinspector import add_introspection_rules

                :return obj: Object of the same class as the one queried.
                """
                if is_primary_language(self.language):
                    return self
                return self.translation_of

            @monkeypatch_method(cls)
            def translation_admin(self, *args, **kwargs):
                """Get HTML with URL to the original translation if available.

                For admin use.

                :return str:
                """
                if self.translation_of:
                    if not PY3:
                        url_title = text_type(self.translation_of)
                    else:
                        url_title = self.translation_of

                    return admin_change_url(
                        self._meta.app_label,
                        self._meta.module_name,
                        self.translation_of.id,
                        url_title=url_title
                    )
                return ''
            translation_admin.allow_tags = True
            translation_admin.short_description = _('Translation of')


            @monkeypatch_method(cls)