https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37472

--- Comment #5 from Matt Blenkinsop <[email protected]> ---
The idea of the work here is to take the existing workflows that we use to
translate core Koha and extend them to be able to work for plugins. There are
two parts to this:

1. We need to extract strings from plugins in development mode and create po
files that can then be translated through pull requests and re-released. (Long
term the plan will be to integrate this into the work being done to create a
centralised plugin store. Plugins admitted to the store could possibly be
integrated into weblate and translated through there).
2. We need to be able to extract newly translated po files from a plugin and
install them alongside any languages already installed on the system.

I’ve tried to make sure there are as few changes as possible required in the
plugins themselves to make rebasing existing plugins easier. Effectively the
only thing that will need doing is ensuring that any template files are stored
in a ‘views/en/‘ folder to mirror the template directory structure we use in
core. This is because the templates will be fetched by get_template_and_user
which substitutes the ‘en’ part of the file path with the desired language.

To test this I’ve forked the kitchen sink plugin as this could then be merged
if this solution is workable and gets pushed to main. We would then have
translation examples in the kitchen sink plugin already. The only changes made
to the plugin itself are moving the template files as described above and also
adding a new javascript file to demonstrate javascript translations.

To test:

1. Clone the fork from: https://github.com/mblenk/dev-koha-plugin-kitchen-sink
into your plugins folder that you would use for ktd --plugins up and checkout
the plugin_translations branch
2. Apply the patches from the bug and run ktd --plugins up to load up ktd with
the plugin installed .
3. Navigate to the plugins page in administration to check the plugin has
installed correctly during ktd start up. You may need to run restart_all if it
is showing an error.
4. Open up the directory for the cloned kitchen sink fork and note the new
configure.js file that has been added, then have a look at configure.tt . I
have added some new strings at the bottom in a list with the id of “js_list”.
One of these is a template string, one is injected from a script tag just
beneath and the third comes from configure.js
5. To extract strings from core koha we use gulp commands like gulp po:create.
I have added a new flag to this to handle plugin strings - run the following
command to extract the strings: gulp po:create  --lang de-DE --plugins
6. Look in the plugin directory and observe that a new folder has been created
called translator. Inside this is a folder called ‘po’ and inside you will find
the template .pot files as well as a folder for de-DE with two .po files in
there. One is for javascript, one for template strings. Open these up and
observe that the strings have been extracted from files and are available to
translate
7. Make some translations for the items in the list on configure.tt that we
looked at in step 4 as well as any other translations that take your fancy.
8. Now we’re going to install the language to see if the plugin translates:
koha-translate --install de-DE --dev kohadev
9. In the plugin directory under the views folder, you will see that a new
folder for de-DE has been created with translated .po files complete with the
translations from step 7.
10. In system preferences, enable the use of German as a language in the
interface
11. Go the plugins page and on the dropdown menu for the kitchen sink plugin
click on ‘Konfigurieren’ to go the configure page
12. Your translations should be visible on the page when German is the selected
language
13. We’ve proven the concept when installing a language with a plugin already
installed, we now need to prove the reverse i.e. that installing a plugin on a
system with languages already installed will update any existing language
translations
14. Run: koha-translate --remove de-DE --dev kohadev
15. In the dev tools, find the cookie for Opaclanguages and delete it
16. Run reset_all
17. As far as Koha is concerned the both the plugin and the language are now no
longer installed so we can now reinstall the language.
18. Repeat step 8
19. Repeat step 10
20. Run perl misc/devel/install_plugins.pl
21. You should see some of the logging from the language installation we saw
earlier (there is also a broken pipe error that needs tracking down and
silencing but this is harmless).
22. Repeat step 11
23. The translations should work as before meaning we now have a translatable
plugin!

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to