bywatersolutions / koha-plugin-room-reservations

This repository is dedicated to the Koha Room Reservation plugin for use with Koha ILS.
GNU General Public License v3.0
4 stars 12 forks source link

Translation #32

Closed lms-tobias closed 3 years ago

lms-tobias commented 3 years ago

Thank you very much, for this great plugin. The plugin has raised some interessest in the german koha community and we would like to offer a translated version to our customers.

What would be the best approach? Would it be possible to implement a translation framework for the plugin or should we fork the plugin and do the translation separetely?

What are your thoughts about this?

Thanks!

kylemhall commented 3 years ago

I've make a POC to add translations to TT files, but it's not working for reasons unknown :/

https://github.com/bywatersolutions/koha-plugin-room-reservations/commit/cf01d555720a0bd48a5293f130873f584800bc0f

lms-tobias commented 3 years ago

Thank you Kyle! That helped me a lot. The only issue with your code was that you forgot to include "use Locale::Messages;" in RoomReservations.pm. After adding this line in worked.

lms-tobias commented 3 years ago

Now, I created a pull request with the fix. There is an issue with utf8 encoding, which is caused by a bug in the Template::Plugin::Gettext module, which comes with libtemplate-plugin-gettext-perl Debian package from the koha-community repo. utf8 is woriking with the CPAN version of the module.

kylemhall commented 3 years ago

Thanks @lms-tobias ! What language did you get it working for? The "test" German file I included? I've added complete translatability to configure.tt. Can you confirm this works and make a pull request with your .po and .mo files? If that works I'll add translatability to the rest of the TT files!

kylemhall commented 3 years ago

I should have noted, these new commits are still on the wip-translations branch: https://github.com/bywatersolutions/koha-plugin-room-reservations/commits/wip-translations

lms-tobias commented 3 years ago

Great, thank you! I just created a pull request with the updated po and mo files. Some strings in configure.tt were not marked with "gettext". I added them as well. But I could not find the 'none' string in the configure.tt image

Is this coming from somewhere else?

kylemhall commented 3 years ago

@lms-tobias it looks like that is coming from the database. If you look at line 614 of configure.tt you'll see the loop that creates it.

lms-tobias commented 3 years ago

@kylemhall ok, I found a way to translate the 'none' strings. Now I will start working on translating the rest of the plugin. Thank you for your help!

kylemhall commented 3 years ago

@lms-tobias fantastic! Do you need me to go through the TT files to make them translatable, or can you do that? Have you seen the directions on how to update the pot, po and mo files?

lms-tobias commented 3 years ago

@kylemhall yes, I have just finished the staff template translations (configure.tt, bookas.tt, tool.tt) and moving forward to the OPAC templates, now.

lms-tobias commented 3 years ago

@kylemhall I added the translation for the OPAC templates as well. But it is not working in the OPAC for some reason. Could it be some Apache settings missing or is there something wrong in the calender.pl?

lms-tobias commented 3 years ago

I have finished the german translation today. There is still a problem with the OPAC translation. It works when I remove [% KohaPlugins.get_plugins_opac_head %] from the 'doc-head-close.inc'. But I am not sure about the impact of this change. We are still on 18.05. I will check the next days, if it works with a newer version.

The translation of the strings coming directly from the perl scripts is not working, yet. It is not a big deal, because that are just a few string, but it would be nice if this could be translated as well.

lms-tobias commented 3 years ago

I completed the German translation. Everything is translated using the gettext engine now. @kylemhall Thank you very much for your help! Much appreciated!

This is how the translation is initialized the first time:

Create POT files from template filles (.tt) xgettext-tt2 --files-from=POTFILES --output=com.marywooduniversity.roomreservations.pot --from-code=utf-8 --force-po

Create PO files from POT file for specific language msginit --input=com.marywooduniversity.roomreservations.pot --locale=de

Add translations to the PO (i.e. using a tool like POEdit) file and create the binary MO file msgfmt --check --statistics --verbose -o de.mo de.po

mv the MO file to the LC_MESSAGES directory and rename it to match the used textdomain. mv de.mo translations/de/LC_MESSAGES/com.marywooduniversity.roomreservations.mo

This is how the translation is updated:

extract translatable strings from perl files PLFILES is a file with a list of perl files

xgettext --files-from=PLFILES \
    --language=Perl \
    --output=plfiles.pot \
    --add-comments="TRANSLATORS: add a few strings" --from-code=utf-8 \
    --force-po

extract translateable strings from .tt files POTFILES is a file containing a list of *.tt files and plfiles.pot (see previous step)

xgettext-tt2 --files-from=POTFILES \
    --output=com.marywooduniversity.roomreservations.pot \
    --add-comments="TRANSLATORS: add a few strings" --from-code=utf-8 \
    --force-po
cp de.po de.old.po
msgmerge de.old.po com.marywooduniversity.roomreservations.pot -o de.po

translate strings in de.po file and create the binary mo file

msgfmt --check --statistics --verbose -o de.mo de.po
mv de.mo translations/de/LC_MESSAGES/com.marywooduniversity.roomreservations.mo

Requirements Template::Plugin::Gettext module from cpan (the debian package provided by the koha-community repository is outdated) cpanm Template::Plugin::Gettext

It might be necessary to install the needed locale on the server. On Debian this is done by editing /etc/locale.gen and uncommenting the lines for the locales that should be enabled. Then run: locale-gen

Known issues: In Koha version 18.05 you need to remove the line [% KohaPlugins.get_plugins_opac_head %] from the 'doc-head-close.inc' header file. Otherwise the translation will not work.

kylemhall commented 3 years ago

@lms-tobias thanks go to you as well! Do you believe this branch is ready to be moved to master?

kylemhall commented 3 years ago

@lms-tobias I think removing the get_plugins_opac_head is a blocker. Do you know if this is a problem with just 18.05, or does it exist in newer versions of Koha?

lms-tobias commented 3 years ago

I think removing the get_plugins_opac_head is a blocker. Do you know if this is a problem with just 18.05, or does it exist in newer versions of Koha?

I tested it with 20.11 and there it was working out of the box.

kylemhall commented 3 years ago

@lms-tobias in that case, I'm comfortable moving this to master if you are!

lms-tobias commented 3 years ago

yes, it should be ok.

kylemhall commented 3 years ago

Merged!