internationalization - Question Editor API

Internationalization

Labels and text rendered by the Question Editor API user interface can be changed or translated to other languages.

Instructions

Attribute paths for label bundles

When adding label bundles, you also need to specify an attribute path. As label bundles do not map exactly to attributes (e.g. there are labels for non-attributes like the add button and content of modal dialogs), the attribute paths for label bundles are slightly different from normal attribute paths. See the docs below for how to find label bundle paths. Each attribute in Question Editor API has a path. For example, the path for the below attribute is validation.valid_response.value[0][0].options.setThousandsSeparator[1].

Why do you need to know about attribute paths?

It's helpful to know the path of an attribute because it then allows you to hide/show/set the defaults for the attribute using base question type, question type templates, or question type templates.

Finding attribute paths

There are two ways to find attribute paths.

  • Use the debug global layout: if you initialize Question Editor API with debug as the global layout (refer to global layout docs for a guide), the attribute path is displayed above every input. This is the preferred option as it also shows you paths for sections which you can hide using hidden_sections.
    Here's an example:
  • Inspect the HTML: if you inspect the HTML, you'll note that the parent div of an input has the attribute data-lrn-qe-input-path.

Finding label bundle paths

To find the paths for label bundles, initialize Question Editor API with the label_bundle.debug flag set to true.

"label_bundle": {
    // debug flag
    "debug": true
}

This will reveal the paths for all label bundle keys on the page. You can override the label for any of these items using label_bundle config.

For array labels (labels with an index number, e.g. Response 1), when changing the label, put an empty space after the label as the number is appended after. E.g. "My Response ". If you wish to change the position of the number, you can use {{index}}. E.g. Response {{index}} value would print Response 1 value for the first index.

Data / Label listing

You can view the label data aggregated in the English/US files in the Learnosity internationalization repository on GitHub.

Further reading

See Translating the Learnosity user interface with label bundles for more information.

Note: support has been added for i18n (internationalization) labels that were previously hard-coded, since version: v2021.1.LTS.

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.