How to change default lanquage of H5P content

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's picture

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

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's picture

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

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's picture

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.