I took a break from back-end dev to do some front-end dev using React. One part of this app will be interactive videos, and for that purpose, I was planning to build an interactive video player. This would be a custom video player that can play multiple videos according to a configuration file, and can accept feedback from the user/student.
This app has now reached a decent level of maturity though it needs more work:
https://github.com/shivkiyer/accordion-player
Now that the interactive video player can be augmented at a gradual pace, it is now time to return to the Django app. So far, the only language supported has been English. For an app to be practically useful, it must support multiple languages, and this would be even more so in the case of an educational app. As an example, most of my students of electrical engineering would have a language other than English as their first language. From the demographics, the biggest language groups would be Spanish, Arabic, Portugese and maybe French and Russian to some extent. This makes the app design interesting for several reasons.
The first is that the webpage has to be in other languages. Though one could argue that most modern browsers come with extensions that perform automatic translation, these extensions do have some limitations. For example, dynamic content that appears in drop down boxes or modals may not be translated. In such cases, where an interaction occurs with the user, it is best that content be generated in the user's preferred language.
The second is with respect to the actual educational content - the video and audio. Here, things get interesting, as many MOOC websites offer an automatic generation of subtitles of uploaded videos, and subsequently translate these subtitles in other languages. One major flaw is that the subtitles generated can be fairly incorrect especially if the speaker is not a native language speaker or has an accent - such as my case. I have found that automatic subtitles generated from my videos are usually full of errors.
Though subtitles are important especially to make the content accessible to those with hearing impairments, learning from reading the subtitles alone would make the videos a bit boring. As of now, there are many AI based translation tools that also allow for translation of audio into other languages. This implies that video content can be made separately available in different languages. Of course the translation may be glitchy, but it will get better with time.
So, for this the first would be to enable a language preference on the front-end. This is quite simple, it can be done on the home page or with a user's account. Once done, all requests made by the front-end to the back-end will contain the "Accept-Language" header, and the back-end will provide content in the language specified in the header. The default language will be English, so if the translated content does not exist, the default English content will be returned.
With Django, this actually turned out much easier than expected. I used the gettext package available with Linux. Apparently, the python-gettext package through pip did not work. Once this was done, the gettext or gettext_lazy can be used to indicate translations to be expected. More on this in a separate post.
Another feature will be to provide translations in the database, and for this I plan to use django-modeltranslation. Both configurations and set up to be described in another post.