Allow to use dynamically created translations
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- frontend, internationalization
Research direction
Start in src/js/language/Language.js around lines 242-251, where the language value is checked before loading a translation resource. Verify how a blob: URL is handled alongside existing JSON URLs, while preserving language-code behavior. Done means dynamically created translation JSON can be passed through a Data URL and used by TimelineJS.
Written by the indexing model from the issue text.
Description
Currently, TimelineJS expects the language property to either
- be a string such as
enindicating that some premade json file from a common path (defaulting tohttps://cdn.knightlab.com/libs/timeline3/latest/js/locale) should be used, or - be a URL string ending with
.jsonindicating 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
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.
- Dominant language
- JavaScript
- Stars
- 3.2k
- Forks
- 645
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NUKnightLab/TimelineJS3
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
NUKnightLab/TimelineJS3#797 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
NUKnightLab/TimelineJS3#617 ·
-
Bug CSS
Difficulty 1/5 Under an hour Newbie friendliness 62/100
NUKnightLab/TimelineJS3#602 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
NUKnightLab/TimelineJS3#904 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
NUKnightLab/TimelineJS3#902 · 2 comments ·
All issues in NUKnightLab/TimelineJS3
Similar issues
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
githubnext/gh-aw-workshop#3692 ·
-
agent/guide documentation hive/hosted-available-lke648397-260827-5n31
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Add: BuyPass TV Openchannels:add check:passed
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
S: triage
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100