h5p-editor-php-library icon indicating copy to clipboard operation
h5p-editor-php-library copied to clipboard

editor field label overrides using alter_semantics hook do only work for English

Open otacke opened this issue 4 years ago • 0 comments

When using the alter_semantics hook, overriding field labels does only work when the platform is set to English.

cause

When loading the editor, the getLibraryData function https://github.com/h5p/h5p-editor-php-library/blob/050a6845bc61f66aecaf3ed4616ca4596ae17481/h5peditor.class.php#L376-L475 is used to gather information to be passed to the browser, among them

  1. the semantics structure https://github.com/h5p/h5p-editor-php-library/blob/050a6845bc61f66aecaf3ed4616ca4596ae17481/h5peditor.class.php#L393 and
  2. the translated labels for the platform's default language https://github.com/h5p/h5p-editor-php-library/blob/050a6845bc61f66aecaf3ed4616ca4596ae17481/h5peditor.class.php#L394

If labels are supposed to be overridden using the alter_semantics hook, then $libraryData->semantics already contains the overrides. Both the semantics structure ($libraryData->semantics) and the translated labels ($libraryData->language) will end up in the browser, where in https://github.com/h5p/h5p-editor-php-library/blob/757f7053cd0af26df95b0f12f0141fe98848cea6/scripts/h5peditor.js#L214 the labels of the semantics will be overridden by the translation labels, thus overwriting the changes that were supposed to be set for the labels.

otacke avatar Jan 14 '21 19:01 otacke