Commit 74810a26 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Add a preferred_language method to relation widget, to ease overriding

parent c4af3f90988a
...@@ -45,7 +45,7 @@ else: ...@@ -45,7 +45,7 @@ else:
languages = set(lang for lang, in self._cw.execute( languages = set(lang for lang, in self._cw.execute(
'DISTINCT Any OLC WHERE ' + baserql + ', O preferred_label OL, ' 'DISTINCT Any OLC WHERE ' + baserql + ', O preferred_label OL, '
'OL language_code OLC', args)) 'OL language_code OLC', args))
for lang in (self._cw.lang, 'en', None): for lang in self.preferred_languages():
if lang in languages: if lang in languages:
break break
else: else:
...@@ -70,6 +70,10 @@ else: ...@@ -70,6 +70,10 @@ else:
entity = self.compute_entity() entity = self.compute_entity()
return entity.e_schema.rdef(rtype, role, tetype) return entity.e_schema.rdef(rtype, role, tetype)
def preferred_languages(self):
"""Return language by order of preference."""
return (self._cw.lang, 'en', None)
@staticmethod @staticmethod
def pref_label_label(concept): def pref_label_label(concept):
return concept.cw_rset[concept.cw_row][2] return concept.cw_rset[concept.cw_row][2]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment