Giter Club home page Giter Club logo

Comments (8)

juho-jaakkola avatar juho-jaakkola commented on August 19, 2024

I know that support for translatable content is a can of worms, but let's brainstorm it anyway!

from h5p-php-library.

fnoks avatar fnoks commented on August 19, 2024

All strings are part of the content json, and altering this backend is possible. Where would the translation come from? And how should it be matched against the strings in the content?

from h5p-php-library.

juho-jaakkola avatar juho-jaakkola commented on August 19, 2024

Braindump:

  1. An "Export" button in the H5P editor finds all the strings and serves them as a CSV file
    • First row is the language code
    • Values in the first columns work as translation keys
  2. Translator adds translations to the other columns of the CSV
  3. The file can now be imported back to the same H5P content
  4. End users can now see a "Change language" dropdown in the content
en nb fi
Apple Eple Omena
Choose Velge Valitse

(CSV used just as an example)

from h5p-php-library.

juho-jaakkola avatar juho-jaakkola commented on August 19, 2024

Would there be any way to generate translation keys automatically?

E.g. second option of a multiselect 1 on the page 2:

page2-multiselect1-option2

These could then be used to match a translation with a piece of content:

key en nb fi
page1-multiselect1-option1 Apple Eple Omena
page1-multiselect1-option2 Strawberry Jordbærfarge Mansikka

from h5p-php-library.

fnoks avatar fnoks commented on August 19, 2024

The way translations are handled in H5P today is both a strength and a weakness. All texts displayed by an H5P is part of the content. Not only typically dynamically content like questions and answers, but also button labels and so on. The idea is that the H5P should look the same when e.g moved to another site.

Technically it would be possible to flatten the content.json hierarchy like you say, and make a unique key for each entry. Furthermore, functionality could be implemented where the translator gets something like the table you have sketched above.

There are a few possible problems with this approach, though. What happens e.g when the author reorders the questions in the quiz? One way of solving this would be to add some kind of unique ID to each leaf in the hierarchy. This ID should never change. Also, structural changes to semantics.json, which means content upgrade changes the content.json, has to be thought of. A unique ID would also solve this scenario.

from h5p-php-library.

juho-jaakkola avatar juho-jaakkola commented on August 19, 2024

What happens e.g when the author reorders the questions in the quiz?

Another braindump: Altering a piece of content (a page? a single element within a page?) would automatically cause invalidation of all the translations related to it. The author would then see a message:

Warning, translations are not in sync with the current structure.
Please export the translation file and add the missing translations.

The idea is that the H5P should look the same when e.g moved to another site.

The translations could be included into the .h5p package just like any other data, right? Therefore the translations could be moved from site to another.

from h5p-php-library.

fnoks avatar fnoks commented on August 19, 2024

As you say, one solution is to invalidate the language file in certain scenarios.

And, It would be possible to include the language files in the H5P package.

from h5p-php-library.

Tuurlijk avatar Tuurlijk commented on August 19, 2024

Don't re-invent the i18n wheel. There are solid solutions for i18n in JavaScript: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Internationalization

from h5p-php-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.