-
-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Add internationalization (i.e. translations and more) support #3107
base: main
Are you sure you want to change the base?
Conversation
|
Hi @jansim, thanks for the PR. I'm afraid what you suggest can already be done using i18next or similar libraries – taking care of all translation needs – so I'm a bit hesitant to build a translation framework from scratch into jsPsych, hence closing this PR. If you're interested in contributing a simple i18next example, that would be great. Cheers! |
@bjoluc I'm working with @jansim and some other folks on this. I'm gonna reopen. Part of the goal here is to make internationalization as easy and integrated as possible to support global research that is hard to do right now. We're also thinking about how to handle non translation components of this. The pointer to i18next is super helpful though. I'm not sure if Jan knew about that already. I certainly didn't. |
Also, I think we're open to the possibility that another tool would be the better way to handle this. But I'd like to make sure that it would cover the same use cases and have the same ease of use that we're after. |
Sorry, I seem to have missed that 🙈
To me, that sounds like the way to go – at least with an API like the one suggested in this PR, it looks straight-forward to use other tools instead. If i18next is too bloated, Polyglot.js might also be a very good option. If the API you envision can only be realized by extending jsPsych, maybe integrate another library, but if I may make a wish, please don't start a full-fledged translation framework here 😶🌫️ We need to maintain this 🥲 |
Very good points, thank you for raising these @bjoluc! I do agree that using an external library could be very useful (and i18next could be a great candidate + a few other interesting libraries out there). However, I do also think that there would be quite some benefit to making this as easy-to-use as possible in the jsPsych context and at least providing a reference implementation. Maybe worth having another chat about how the ideal solution would look here? Would definitely good to be aligned on this to avoid unnecessary implementations 🤔 |
Hmm, so I feel we have four options here in terms of whether/how we could use external libraries:
Do you have any clear feelings on which approach you would think is the most suitable here? I'm leaning a bit towards 2. or 3., as I don't want to create too much extra maintenance work. My main reason for not being convinced by 1. is that IMO one quite valid use-case in jsPsych would be to create re-usable trials where you would want to have their translations side-by-side with the trial code itself. I think instance & translation management for this would be quite difficult in most / any existing i18n library as this is a sort of unusual use-case. I do believe we could fix this with some wrapper code, though, but that's option 2. then. |
Right, very valid point. When suggesting (1) above, I thought about adding translations separately next to each trial or in a trial callback, but that is definitely not as nice as a trial-level Pro (3):
Pro (2):
I think what's important if settling on (3) is that we expose the API of the underlying library as much as possible and are transparent about it in the docs to avoid reinventing the wheel documentation-wise and retain all of the original lib's flexibility. Which certainly would be easier to do with (2) 🤔 I'm on the fence. |
Yep, agree 100%. I'm also usually very hesitant to introduce too much extra code to any sort of project as long as it could be avoided. If we're all fine with deciding between (2) and (3), we could just make it dependent on the size of the final library we end up with. The benefit of these two options is also that they will most likely be very similar in how a lot of the code around them looks, so we could still pivot late in the process. |
My instinct here is that jsPsych bundle size is not a huge concern for most research projects. Jan's might be one of the few projects where bundle size is a relevant cost consideration given the huge volume of traffic and global reach. Obviously avoiding unnecessary bloat is good, but given a tradeoff between usability and bundle size I'd lean towards usability. |
Haha, compared to the size of the MP3 files and stuff, we also don't pay too much attention to bundle size. It's more just some lean-solution-perfectionism coming through 😄 |
This (currently WIP) PR adds support for internationalization i.e. translations and all other necessary features to make experiments available in different languages / locales.
Feedback and ideas are welcome.
(Non-Exhaustive) Todo List:
Hello World!
toHallo Welt!
Hello {name}!
toHallo {name}!
translateKeyboard(['a'])
; KeyboardMap API