Translating content.json text

We are looking to translate the course content in the h5p courses. I originally thought we would have to follow the process described in the translate libraries page, but all of the content that we actually need translated is contained within the content.json file of the content folder. This JSON file seems to include all of the required activity text and the text included in the editable "Text overrides and translations" fields. The semantics.json files don't seem to include any of the text from the activity questions.

My question is: if we translate this content offline, how can we import the translated h5p files back into the h5p platform? Do we follow the same process of creating a languages folder within the content folder, and adding the translated language files back in with the corresponding language code? Or is there a different process for this file?

Thank you!

Well, we tried adding the language folder with the translated json file to the content folder but no luck. We got this message instead. If anyone has any suggestions on how to import the translated content file that would be appreciated! 

Validating h5p package failed.

File "content/" not allowed. Only files with the following extensions are allowed: json png jpg jpeg gif webm mp4 ogg mp3 m4a wav vtt webvtt txt gltf glb-allowed.Get help

File "content/language/" not allowed. Only files with the following extensions are allowed: json png jpg jpeg gif webm mp4 ogg mp3 m4a wav vtt webvtt txt gltf glb-allowed.Get help

otacke's picture

That's what you get if the h5p file was not zipped with the flags -X and -D (plenty of posts on this forum) ...

Thank you! We have now figured out the folder issue and successfully uploaded the folder to the h5p editor. But none of the translated content displayed in the target language, so we're obviously still not doing something right.

We couldn't seem to find the actual question content strings in any of the semantics.json files, only in the content.json file. But adding the language file for that translated content in a language folder doesn't seem to do the trick either.

H5P file: 
Attachments: 
otacke's picture

You cannot have more than one language in an H5P file, so adding a language folder into the content folder serves no purpose.

You'll have to replace the contents of content.json with what you have put into language/es-mx.json, and additionally you should set the value of the "language" key in h5p.json to "es-mx".

Ok, thanks to otacke for his responses we have figured out a way to translate activities. Documenting it here in case others have the same issues:

  1. Export the .h5p file form the platform and unzip locally
  2. Locate the content folder and content.json file
  3. Import this content.json into your preferred CAT tool, exluding values for the following keys:
    "subContentId""library""title""contentType""license"There may also be other activity-specific keys that refer to activity settings and which should not be translated, such as "dropZoneHighlighting" for Drag and Drop activities.
  4. Once translated, replace the original content.json file with the translated version.
  5. In the original unzipped .h5p, find the h5p.json file and locate the “language” key. Change the language code value from the default (probably "en") to the one corresponding to your target language (as per this list).
  6. If there is a “defaultLanguage” file as well, do the same to this file.
  7. Re-zip the folders as a .h5p file type using the H5PCLI tool or manually, making sure you include the -D and -X flags. If the file was unzipped on a Mac you will also need to remove the .DS_Store files.
  8. Upload the translated .h5p file to the H5P editor platform. Both the activity content and the activity strings should be in your target language.