Exemplo n.º 1
0
    def extract_field_analyzed_translations(cls, obj, field, db_field=None):
        """
        Returns a dict containing translations for each language-specific
        analyzer for the given field.
        """
        if db_field is None:
            db_field = '%s_id' % field

        extend_with_me = {}

        # Indices for each language. languages is a list of locales we want to
        # index with analyzer if the string's locale matches.
        for analyzer, languages in SEARCH_ANALYZER_MAP.iteritems():
            extend_with_me['%s_%s' % (field, analyzer)] = list(
                set(string for locale, string in obj.translations[getattr(
                    obj, db_field)] if locale.lower() in languages))

        return extend_with_me
Exemplo n.º 2
0
    def extract_field_analyzed_translations(cls, obj, field, db_field=None):
        """
        Returns a dict containing translations for each language-specific
        analyzer for the given field.
        """
        if db_field is None:
            db_field = '%s_id' % field

        extend_with_me = {}

        # Indices for each language. languages is a list of locales we want to
        # index with analyzer if the string's locale matches.
        for analyzer, languages in SEARCH_ANALYZER_MAP.iteritems():
            extend_with_me['%s_l10n_%s' % (field, analyzer)] = list(
                set(unicode(string) for locale, string
                    in obj.translations[getattr(obj, db_field)]
                    if locale.lower() in languages))

        return extend_with_me