Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getLabel does not return the appropriate language #201

Open
twistoliver opened this issue Jun 30, 2016 · 0 comments
Open

getLabel does not return the appropriate language #201

twistoliver opened this issue Jun 30, 2016 · 0 comments

Comments

@twistoliver
Copy link

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.
    capture
    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:

        public function getLabel()
    {
        if (is_null($this->label)) {
            // try to get the label in the user data-language
            $labels = $this->getPropertyValuesByLg ( new core_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(new core_kernel_classes_Property(RDFS_LABEL));
            }
            $this->label = ((is_null($label) === false) ? $label->literal : '');
        }

        return $this->label;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant