Hi David,

I think that language descriptions would be best in a Perl module, so that they can be used everywhere (perl and templates).

For instance:

package Koha::Languages;
use Koha::I18N;
sub getLanguages {
    return {
        en => __('English'),
        fr => __('French'),
    }
}

And if the original description is needed, we can do the same but without the __() translation.

sub getLanguagesDescriptionsInTheirOwnLanguage {
    return {
        en => 'English',
        fr => 'Français',
    }
}

Le 26/04/2021 à 02:44, dc...@prosentient.com.au a écrit :
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 <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&bug=12017&attachment=40285 <https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&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


_______________________________________________
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/


--
Julian Maurice
BibLibre
_______________________________________________
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/

Reply via email to