H5P Guides

Add translation

H5P libraries have built-in support for translation of static strings in the library semantics, such as titles, descriptions and defaults. This is done by including language files that are merged on top of the semantics object.

Let's add support for Norwegian (bokmål) to the H5P.GreetingCard library. First create the directory "greeting/H5P.GreetingCard/language", then add the file "nb.json" with the following content:

{
  "semantics": [
    {
      "label": "Velkomsttekst",
      "default": "Hallo verden!",
      "description": "Velkomstteksten som vises til sluttbruker."
    },
    {
      "label": "Bilde til kort",
      "description": "Bildet som vises på kortet. Valgfritt, uten bilde vises bare teksten."
    }
  ]
}

Only replace the strings used and leave out other fields, such as "name" and "optional". It is important not to translate the name, since this is used in code.

After translating, the editor will look as below, if the site is set to 'Norwegian Bokmål".

If you're able to upload the library and view/edit the Greeting card, you have successfully completed this tutorial! 

Good luck creating your own H5P libraries! If you get stuck, reach out to the community in the forums.