How do translations work?

Forums: 

This is my first post here, so... hello, everyone!

I've been trying to setup a website where users can create H5P content and make it available for others. The website is geared towards Brazil, so it must offer Brazilian Portuguese text. I'm using H5P as a plugin of Wordpress 5.2.2, running on Ubuntu 18.04. So far, I have been able to get pt_BR text in Wordpress itself, and in the H5P Hub UI (except for library descriptions). In the H5P Editor, however, for some libraries, labels for input fields are all shown in Portuguese, while for others the "Title" input field label is in Portuguese, while all other labels are in English. You can see some correct output here and incorrect output here.

From what I understand, the H5P Editor bases these input field labels off each library's semantics.json file, or, if the display language isn't English, from "subsets" of it implemented in files in the library's language directory. However, in those cases where "Title" is in Portuguese and other labels are in English, there is a pt_BR.json file. Upon comparison with a language that is being correctly displayed, the pt_BR file  seems structurally equivalent to the working language's (e.g., ja.json) file.

Unable to pinpoint a cause for this problem, I also couldn't tell in which repository to create an issue for it. Since I'm running H5P on Wordpress, and given that Wordpress is responsible for informing H5P of the selected display language, I decided to open an issue on the Wordpress plugin repository. I still remain unsure, though, if the problem really is there, in the libraries themselves, or somewhere in the H5P core.

I ask, then: how does H5P take translations and output it into, say, the H5P Editor? I've tried looking into some PHP and JS files, but neither of these languages is my forte, and the code seems abstracted enough that I can't quite tell what "path" the data from translation files takes from being opened to being output in the HTML page. Also, were I to simply try and change the English text to Portuguese in the original source... what would that source be? How would I set that change into effect? On my search on how to solve this problem I've read about having to change version numbers to put changes in effect, but I'm not sure if that's necessary in my particular case or not. 

Any answers or pointers to documentation I may have missed are greatly appreciated! 

papi Jo's picture

I'll try to help...

Unfortunately the translation process in H5P is incredibly complicated. First, the language strings have to be translated for the 3 different plugins available in the 3 platforms: Drupal, Moodle and Wordpress. Each of which has its own translation process.

Then the contents/activities themselves have to be translated, based, as you found out, on the original semantics.json file (in English) which is present in each activity library. Even if most H5P libraries are available with lots of languages in their /language folder, it does not mean that these translations exist. Quite often they are still in the original English language.

Now these are my findings re your Brazilian Portuguese translations.

  • H5P multiple choice is NOT translated into pt, but is translated into pt_br
  • H5P drag the words/dragtext is translated into pt and into pt_br

for example, we see the following differences:

pt: "label": "Descrição da atividade"
pt-br: "label": "Descrição da tarefa"

In Drupal with pt and pt-br languages installed, things work as expected for H5P drag the words: in edit mode WE SEE:

pt: Descrição da atividade /Descreva a forma como o utilizador vai completar a atividade.

pt-br: Descrição da tarefa / Descreve como o usuário deve resolver a tarefa.

In WordPress with pt and pt-br languages installed, things DO NOT work as expected for H5P drag the words:: in edit mode WE SEE:

pt:Descrição da atividade / Descreva a forma como o utilizador vai completar a atividade.

pt-br:Descrição da atividade / Descreva a forma como o utilizador vai completar a atividade. (the same translation!)

What you see on your attached screenshot https://user-images.githubusercontent.com/1574303/64121656-db8f9a80-cd75... is in fact the pt translation, NOT the pt-br translation.

It seems that WordPress + H5P is unable to differenciate between language translations with a double digit (pt) and the extended version (pt-br). This problem is not easy to test because as far as I can see in the H5P language libraries, portuguese is the only one with the 2 variants!

Now we come to the other problem, the H5P Multiple Choice activity, shown on your screenshot at https://user-images.githubusercontent.com/1574303/64121544-7cca2100-cd75...

It's very easy to explain, considering the above. Because H5P in WordPress is unable to differenciate between pt and pt-br, AND Multiple Choice has not been translated into pt, the interface appears in the original English!

I have attached a screenshot from my Drupal site, where Mutliple Choice is correctly displayed in pt.

-----------------------------

Conclusions

Do not do anything on your site, you risk to crash things!

This seems to be a bug in the WordPress H5P plugin. I expect someone from H5P will be reading this and post a bug report.

 

 

 

 

BV52's picture

Hi Papi,

Thank you for the thorough diagnosis of the issue. I added a comment in the github repo issue that was created by lalilulelost. We'll just have to wait for the core team to check this.

-BV52

papi Jo's picture

Just to say that things work as expected in Moodle, like in Drupal.

So this seems to be definitely a WordPress H5P plugin issue.