How to change default lanquage of H5P content
Submitted by init90 on Mon, 04/11/2022 - 12:42
Forums:
Hello all,
maybe someone can advise how to specify the default content language or even limit the languages list?
Some info:
We use H5P with Drupal.
Currently, we use the next solution for that:
Drupal.behaviors.H5P_customization = { attach: function (context, settings) { if (drupalSettings.h5peditor) { // Set up default H5P language to German. drupalSettings.h5peditor.language = 'de'; } } }
Unfortunately, it works only partly, the default language in select really German, but for some reason, not all translations are updated.
When switch language to German from select then everything is ok, all translations are updated.
otacke
Tue, 04/12/2022 - 11:35
Permalink
Hi!I don't know Drupal well,
Hi!
I don't know Drupal well, but I assume that the `attach` callback is executed when the DOM has been loaded and H5P core will have determined the language used by the host platform before it renders anything.
Best,
Oliver
init90
Tue, 04/12/2022 - 15:07
Permalink
Oliver, thanks for the answer
Oliver, thanks for the answer.
Correct the `attach` callback is executed when the DOM is fully loaded, but in h5peditor-form.js default language is correct.
Also, I've tried to pass the lang code immediately without waiting on DOM load, and it works, but the issue described in the summary still exists.
otacke
Tue, 04/12/2022 - 20:36
Permalink
Hi!Then you may want to
Hi!
Then you may want to elaborate on what "it works only partly" means exactly. Otherwise, I fear, your chances for help are slim.
Best,
Oliver
init90
Wed, 04/13/2022 - 10:22
Permalink
yes, you are right.Let's omit
yes, you are right.
Let's omit the word "partly" because it's not very correct.
Default language programmatically set to German (see default_lang_de.png)
After manual language switch with UI (see manual_lang_switch.png)
otacke
Thu, 04/14/2022 - 14:49
Permalink
I think the language
I think the language parameter in `h5p-editor-form.js` is used to set the defaults for the translations within the content (not the editor form itself), but potentially it only sets the `select` field value and it's not yet actually loading the translations. That would be a bug in H5P core then, I guess.
developer246
Mon, 04/29/2024 - 16:49
Permalink
Same problem
Hi, I have same problem right now, did you find out how to solve it?