[Koha-devel] Template::Toolkit and Translations

dcook at prosentient.com.au dcook at prosentient.com.au
Mon Apr 26 02:44:30 CEST 2021


Hi all,

 

While I mostly work in English, I occasionally do support libraries in other
languages like French, Arabic, and Chinese. And more recently I’ve been
looking at the Languages dropdown in the OPAC advanced search.

 

In the templates, I notice that we often translate HTML, but what if we
translated strings for a Template::Toolkit data structure instead? 

 

Consider the following:

[% BLOCK en %]Anglais[% END %]

[% BLOCK fr %]Français[% END %]

[% langs.en = INCLUDE en %]

[% langs.fr = INCLUDE fr %]

 

I suppose it’s not very beautiful, but the translation process should be
simple and in the end we have a re-usable hash map rather than static HTML. 

 

As I commented on Bug 12017
(https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12017), we could
have a database table of language codes with native language names, and then
iterate through that and use the hash map of translations to provide the
translations. Since we’re not producing HTML, we could flexibly reuse this
language data in various different contexts. Whether it’s the Languages
dropdown in the OPAC advanced search, the language selector, or whatever. 

 

We could probably use this concept in other places as well where we need
translations but we don’t want to be bound to HTML. 

 

What do people think? I’m not wedded to the idea, but it’s something that
crossed my mind this morning, when I looked at the large switch statements
at https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html
<https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=120
17&attachment=40285> &bug=12017&attachment=40285. 

 

(To that end, I would also suggest a theme-independent Template::Toolkit
include directory, but that’s another story
)

 

David Cook

Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20210426/728a85eb/attachment.htm>


More information about the Koha-devel mailing list