--- a/src/pyams_content/shared/common/zmi/search.py Wed Sep 20 12:12:58 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/search.py Thu Sep 21 12:00:57 2017 +0200
@@ -20,6 +20,7 @@
from pyams_content.profile.interfaces import IAdminProfile
from pyams_content.shared.common.interfaces import ISharedTool
from pyams_content.shared.common.interfaces.zmi import ISharedToolDashboardTable
+from pyams_i18n.interfaces import INegotiator
from pyams_pagelet.interfaces import PageletCreatedEvent
from pyams_sequence.interfaces import ISequentialIntIds
from pyams_skin.interfaces import IPageHeader, IContentSearch, IInnerPage
@@ -98,9 +99,15 @@
params &= Eq(catalog['oid'], sequence.get_full_oid(query))
else:
query_params = Eq(catalog['oid'], sequence.get_full_oid(query))
- index = catalog['title:' + self.request.registry.settings.get('pyramid.default_locale_name', 'en')]
- if index.check_query(query):
- query_params |= Contains(index, ' and '.join((w+'*' for w in query.split())))
+ negotiator = get_utility(INegotiator)
+ for lang in {self.request.registry.settings.get('pyramid.default_locale_name', 'en'),
+ self.request.locale_name,
+ negotiator.server_language} | negotiator.offered_languages:
+ index_name = 'title:{0}'.format(lang)
+ if index_name in catalog:
+ index = catalog[index_name]
+ if index.check_query(query):
+ query_params |= Contains(index, ' and '.join((w+'*' for w in query.split())))
params &= query_params
return unique(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
CatalogResultSet(CatalogQuery(catalog).query(params,
@@ -171,9 +178,15 @@
params &= Eq(catalog['oid'], sequence.get_full_oid(query))
else:
query_params = Eq(catalog['oid'], sequence.get_full_oid(query))
- index = catalog['title:' + self.request.registry.settings.get('pyramid.default_locale_name', 'en')]
- if index.check_query(query):
- query_params |= Contains(index, ' and '.join((w+'*' for w in query.split())))
+ negotiator = get_utility(INegotiator)
+ for lang in {self.request.registry.settings.get('pyramid.default_locale_name', 'en'),
+ self.request.locale_name,
+ negotiator.server_language} | negotiator.offered_languages:
+ index_name = 'title:{0}'.format(lang)
+ if index_name in catalog:
+ index = catalog[index_name]
+ if index.check_query(query):
+ query_params |= Contains(index, ' and '.join((w+'*' for w in query.split())))
params &= query_params
if data.get('owner'):
params &= Eq(catalog['role:owner'], data['owner'])