You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
core_kernel_classes_Resource->getLabel() does not return the appropriate language after translation.
Scenario in TAO user interface:
If the default data-language of the platform is 'en-US'
If the user data-language is 'fr-FR'
If a new instance of Item is created
If the label is changed to 'FR_item'
If the Item label is translated to 'English' with name 'EN_item'
If the interface is reloaded
The label of the Item in the instance tree is displayed in English instead of French while correctly displayed in the label field of the instance properties editing form.
The problem is linked to the Resource->getLabel function that is calling onePropertyValue... that is calling getPropertyValues. In this function, the SQL query is searching for 'fr-FR'(user data-language), '' (empty language) or 'en-US' (platform default). Then sort them by id (kind of date of creation sort) descending and take the first one (limit 1). In previous scenario the last one created is en-US (due to translation). That's why the label in 'en-US' is returned instead of 'fr-FR'.
To bypass this issue I modified getLabel function directly, but you will probably adopt a better approach:
publicfunctiongetLabel()
{
if (is_null($this->label)) {
// try to get the label in the user data-language$labels = $this->getPropertyValuesByLg ( newcore_kernel_classes_Property ( RDFS_LABEL ), common_session_SessionManager::getSession ()->getDataLanguage () );
if (!$labels->isEmpty()) {
$label = end($labels->sequence);
}else{
// traditional request to get a value$label = $this->getOnePropertyValue(newcore_kernel_classes_Property(RDFS_LABEL));
}
$this->label = ((is_null($label) === false) ? $label->literal : '');
}
return$this->label;
}
The text was updated successfully, but these errors were encountered:
core_kernel_classes_Resource->getLabel() does not return the appropriate language after translation.
Scenario in TAO user interface:
The problem is linked to the Resource->getLabel function that is calling onePropertyValue... that is calling getPropertyValues. In this function, the SQL query is searching for 'fr-FR'(user data-language), '' (empty language) or 'en-US' (platform default). Then sort them by id (kind of date of creation sort) descending and take the first one (limit 1). In previous scenario the last one created is en-US (due to translation). That's why the label in 'en-US' is returned instead of 'fr-FR'.
To bypass this issue I modified getLabel function directly, but you will probably adopt a better approach:
The text was updated successfully, but these errors were encountered: