[html gen] Use _concept_value from profile generation to properly handle every possible languages
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 03 Nov 2016 18:27:10 +0100
changeset 1957 b62759f45f71
parent 1956 d6df3fe381be
child 1958 3e304ec4cff8
[html gen] Use _concept_value from profile generation to properly handle every possible languages The scheme may contains generic 'seda' values. This function properly deal with every possible language.
entities/html_generation.py
--- a/entities/html_generation.py	Tue Oct 25 14:14:52 2016 +0200
+++ b/entities/html_generation.py	Thu Nov 03 18:27:10 2016 +0100
@@ -20,7 +20,7 @@
 from cubicweb import _
 
 from cubes.seda.entities.profile_generation import SEDA2ExportAdapter, content_types
-from cubes.seda.entities.profile_generation import xselement_scheme_attribute
+from cubes.seda.entities.profile_generation import xselement_scheme_attribute, _concept_value
 
 
 def element_uml_cardinality(occ, card_entity):
@@ -275,12 +275,9 @@
                 href, label = value.absolute_url(), value.dc_title()
             elif value.cw_etype == 'Concept':
                 href = value.absolute_url()
-                try:
-                    label = value.labels['seda-2']
-                    if value.label() != label:
-                        label = '{0} ({1})'.format(label, value.label())
-                except KeyError:
-                    label = value.labels['en']
+                label = _concept_value(value, 'seda-2')
+                if value.label() != label:
+                    label = '{0} ({1})'.format(label, value.label())
             elif hasattr(value, 'id'):
                 # value is something in the profile which has a id (e.g. archive unit, data object)
                 href, label = '#{0}'.format(value.id), value.id