Currently, TimelineJS expects the language property to either
be a string such as en indicating that some premade json file from a common path (defaulting to https://cdn.knightlab.com/libs/timeline3/latest/js/locale) should be used, or
be a URL string ending with .json indicating that some particular premade json file should be used.
It is not possible, however, to use dynamically created language overrides, which would commonly be passed as a JSON object following the same structure as the translation JSON files.
if (
/\.json$/.test(code) ||
/^blob:/.test(code) // dynamically created file (Data URL)
) {
then in particular 3rd party solutions that use TimelineJS as module could simply construct their own translation JSON object dynamically (let us call it foo) and pass it to TimelineJS as a Data URL, e.g. using
URL.createObjectURL(new Blob([JSON.stringify(foo)])) // in proper `try/catch`-clause, sure
If that's something that feels worth adding to TimelineJS (implementation can vary, of course), please let me know.
Currently, TimelineJS expects the
language
property to eitheren
indicating that some premade json file from a common path (defaulting tohttps://cdn.knightlab.com/libs/timeline3/latest/js/locale
) should be used, or.json
indicating that some particular premade json file should be used.It is not possible, however, to use dynamically created language overrides, which would commonly be passed as a JSON object following the same structure as the translation JSON files.
A simple change to https://github.com/NUKnightLab/TimelineJS3/blob/master/src/js/language/Language.js#L242-L251 would allow this. If, for instance, the initial check at https://github.com/NUKnightLab/TimelineJS3/blob/master/src/js/language/Language.js#L243 was turned into
then in particular 3rd party solutions that use TimelineJS as module could simply construct their own translation JSON object dynamically (let us call it
foo
) and pass it to TimelineJS as a Data URL, e.g. usingIf that's something that feels worth adding to TimelineJS (implementation can vary, of course), please let me know.