# -*- coding: utf-8 -*-
from django.conf import settings
from cms.utils.i18n import get_current_language

from haystack import routers
from haystack.constants import DEFAULT_ALIAS


class LanguageRouter(routers.BaseRouter):

    def for_read(self, **hints):
        language = get_current_language()
        if language not in settings.HAYSTACK_CONNECTIONS:
            return DEFAULT_ALIAS
        return language

    def for_write(self, **hints):
        language = get_current_language()
        if language not in settings.HAYSTACK_CONNECTIONS:
            return DEFAULT_ALIAS
        return language

# -*- coding: utf-8 -*-
from django.conf import settings
from django.utils.translation import get_language
from cms.utils.i18n import alias_from_language

from haystack import routers
from haystack.constants import DEFAULT_ALIAS


class LanguageRouter(routers.BaseRouter):

    def for_read(self, **hints):
        language = get_language()
        alias = alias_from_language(language)

        if alias not in settings.HAYSTACK_CONNECTIONS:
            return DEFAULT_ALIAS
        return alias

    def for_write(self, **hints):
        language = get_language()
        alias = alias_from_language(language)

        if alias not in settings.HAYSTACK_CONNECTIONS:
            return DEFAULT_ALIAS
        return alias

Implement Paulo tip about router.