@missing-elements/h5p-embed 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -66,6 +66,7 @@ It works at a domain's root or under a path, over https. Serve `h5p-sw.js` with
66
66
  | `preload=auto` | Start fetching media at once |
67
67
  | `activity-id=<IRI>` | The xAPI object id, instead of the package URL |
68
68
  | `custom-css=<url>` | A stylesheet loaded into the content |
69
+ | `lang=<tag>` | The language of H5P's own buttons and dialogs, such as `de` or `pt-BR`. Default: English |
69
70
  | `xapi=<origin>` | Relay statements to the embedding page |
70
71
 
71
72
  A custom script and a learner's name cannot be set on the address. Opened unframed, the page asks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@missing-elements/h5p-embed",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Self-hosted H5P embeds: writes the H5P embed page as a static site for a player domain of your own, then any site frames it with an iframe and one script line. No H5P server, no third-party service; optional allowlists for package hosts and embedding sites.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,8 +44,8 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "@missing-elements/h5p-libraries": "^0.1.1",
47
- "@missing-elements/h5p-offline-player": "^0.6.1",
48
- "@missing-elements/h5p-runtime": "^0.1.1"
47
+ "@missing-elements/h5p-offline-player": "^0.6.2",
48
+ "@missing-elements/h5p-runtime": "^0.1.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^26.6.4",
package/site/embed.js CHANGED
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * ?src=<package url>[&libraries=pack|<url> …|none][&preload=auto][&xapi=<parent origin>]
9
9
  * [&frame][&copyright][&export][&icon][&reporting][&fullscreen=off]
10
- * [&activity-id=<IRI>][&custom-css=<stylesheet url>]
10
+ * [&activity-id=<IRI>][&custom-css=<stylesheet url>][&lang=<language tag>]
11
11
  *
12
12
  * Upward it speaks H5P's own resizer protocol — the `hello` / `resize` exchange that h5p.org's
13
13
  * embed code and its `h5p-resizer.js` use — so a page that already resizes h5p.org iframes
@@ -243,9 +243,10 @@ export function startEmbed({ librariesPack = null, packages = null, defaultLibra
243
243
  * The element's display options, by their attribute names, for the embedding page to ask for:
244
244
  * `&frame&copyright&export` shows H5P's action bar with those buttons, `&fullscreen=off` takes
245
245
  * that one away, `&activity-id=` names the statements' object and `&custom-css=` restyles the
246
- * content to the embedding site's taste. Not `custom-js`, `embed-code` or `user`: a script is
247
- * a capability on this origin that a link should not hand out, the embed is the embed, and a
248
- * learner's name has no place in a URL.
246
+ * content to the embedding site's taste. `&lang=` is the embedding page's language, which this
247
+ * page cannot read across origins: H5P's own buttons and dialogs follow it. Not `custom-js`,
248
+ * `embed-code` or `user`: a script is a capability on this origin that a link should not hand
249
+ * out, the embed is the embed, and a learner's name has no place in a URL.
249
250
  */
250
251
  const applyOptions = () => {
251
252
  for (const name of ['frame', 'copyright', 'export', 'icon', 'reporting']) {
@@ -256,6 +257,8 @@ export function startEmbed({ librariesPack = null, packages = null, defaultLibra
256
257
  const value = params.get(name)?.trim()
257
258
  if (value) player.setAttribute(name, value)
258
259
  }
260
+ const lang = params.get('lang')?.trim().replaceAll('_', '-')
261
+ if (lang && /^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/.test(lang)) player.setAttribute('lang', lang)
259
262
  }
260
263
 
261
264
  const start = (value, libraries) => {