Texts are not translated

Forums: 

I'm developing an editor widget and having trouble with the translation. What I've done so far is:

  • Created a directory called "language"
  • Created a file called "de.json"
  • Add the translations to "de.json":
  libraryStrings: {
    "loading": "Laden..."
  }
  • Add the following lines to the end of my script:
H5PEditor.language['H5PEditor.MyWidget'] = {
  libraryStrings: {
    "loading": "Loading..."
  }
};

In the source I use "H5PEditor.t('H5PEditor.MyWidget', 'loading') to translate the text. Finally, I use "h5p pack -r MyWidget" to create the h5p file. But unfortunately, it's not translating to German. I always see the English word "Loading...". I ensured that the "de.json" is part of the h5p file created. Any suggestions why it's not translating? I'm already award of https://h5p.org/documentation/for-developers/translate-h5p-libraries but I think I've done everything correctly...

otacke's picture

Hi!

Sounds alright. Have you checked that it is not a caching issue? Have you set a breakpoint at https://github.com/h5p/h5p-editor-php-library/blob/master/scripts/h5peditor-editor.js#L591 to see what the t function is doing?

Best,
Oliver

Thank you Oliver! That was exactly the problem. I'd to clear the cache. I thought I cleared it, but obviously that was not the case.

otacke's picture

Hi mstimvol!

We have all been through things like this :-)

Best,

Oliver