h5p-editor-php-library
h5p-editor-php-library copied to clipboard
editor field label overrides using alter_semantics hook do only work for English
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
- the semantics structure https://github.com/h5p/h5p-editor-php-library/blob/050a6845bc61f66aecaf3ed4616ca4596ae17481/h5peditor.class.php#L393 and
- 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.