Submitted by ksen-pol on Mon, 12/14/2020 - 00:16
Hello! I am trying to make translations to work by default. So I follow https://h5p.org/documentation/for-developers/translate-h5p-libraries
Can you help me? In what folder can I find the semantics.json file?
And where should I put it after adding translation?
Can you also help me with finding the list of already made translations into Russian?
Mon, 12/14/2020 - 09:00
I think I found the path
I think I found the path
Mon, 12/14/2020 - 22:04
I have made some test
I have made some test translations and I have placed the file in the folder. But I still can not see the translations.
In the file I have e.g.
Is it right?
What else should I do?
Where can I find the reason?
Tue, 12/15/2020 - 18:09
Hi ksen-pol!There's more than
There's more than one reason this will not work, I fear.
You cannot add the <strong> tag here, you're not editing an HTML file, but a JSON file. You broke its syntax there. Besides, even if you put the <strong> tag inside the quotes, this would not work, because the labels are not interpreted as HTML but as plain text.
Then, even if that would work, it would not load right away, because H5P doesn't read the language files every time you open content (unless your platform is in development mode - possibly, not sure here), but it copies the contents to the database (table h5p_libraries_languages) when the content library is installed and then retrieves translations from the database. You'd have to update the database as well.
Also, please note that your changes will be overwritten once you update the library.
If you want to restyle the label appearance, you should use the alter_styles hook and override the editors stylesheet. It may be cumbersome, however, to target single fields.
Tue, 01/12/2021 - 14:14
translations for old nodes
Thank you, Oliver! I had updated the library (I had installed the new versions of some libraries automatically from the hub UI). And in the folder files/h5p/libraries I found existing translation into needed language.
When I create new content nodes translations now work properly. But when I open old interactive content nodes I see that buttons translations were not added for them.
So I now with new versions I don't need to create my own translations and to worry how to make hem work afer updating. now I need to make my old nodes to use this translations.
How can I add translations to buttons for old nodes?
I have two ideas how to do it.
1)To copy files from the new updated version of the library and to put it into the languages folder of new old one
2) or as you told before to update the database somehow
How can I update the database?
“drush updatedb” does not help
You wrote that when H5P copies the contents to the database (table h5p_libraries_languages) when the content library is installed it is possible to retrieve translations from the database. How can I update the database to affect old nodes also?
Tue, 01/12/2021 - 19:09
Hi ksen-pol!If it works for
If it works for new content: great! But keep in mind that your changes will be overwritten whenever you update the libraries.
When you update existing content to newer versions of the libraries (using the green arrows on the library settings page "Content->H5P Libraries"), then the fields' labels in the editor should bear your translation. If you are asking for the button labels in the view, after updating the content you'd have to switch the language to some other language first and then switch back to Russian.
Ideally, these changes should not be made by altering the files directly, but by using the alter_semantics hook.
Wed, 01/13/2021 - 14:08
Thank you very much.I still
Thank you very much.
I still could not change some button labels in old content. I don’t understand what else should I do.
I had updated existing content to newer versions of the libraries (using the green arrows on the library settings page "Content->H5P Libraries"), and the fields' labels now have new translation.
But I still could not change button labels in the view. In the process of updating the content I switched the language to English first and then switched back to Russian. But buttons are still in English.
I had also cleared the cach of Drupal site and on the h5plibraries page, I started cron manually. It did not help.
But I did not understand how to use the alter_semantics hookfor this?
In what file what should I change?
And I understood that altering the files directly is a bad way but even this way I am not sure I used correct: I saved old content with new language settings by pressing “save” button on the node editing page. And then saved the same way but with Russian language.
(screenshoots are below)
And even when I copy and paste content using buttons on the top of content editing page (e.g. course presentation) all the the button labels (such as 'check') are still in English.
Settings for choosing language are on the scrennshoot also.
Wed, 01/13/2021 - 15:31
Hi ksen-pol!I am sorry, I don
I am sorry, I don't have the time/leisure to give you a full tutorial on how to use the alter_semantics hook. Maybe someone else has.
One of the images shows that you still need to rebuild the content type cache by pressing the button right below: make it so.
If you are modifying translation files directly, then the aforementioned database table ("h5p_libraries_languages") is not updated automatically. You'd have to
That should replace the strings using the method described in the previous post.
Please note that you can also manually check/replace buttons' translations when you create content, just in case ...