[Koha-bugs] [Bug 36297] Avoid using var named "t" in templates

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Mar 15 13:52:09 CET 2024


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

--- Comment #6 from Pedro Amorim <pedro.amorim at ptfs-europe.com> ---
(In reply to Julian Maurice from comment #4)
> Remember that there is also 'tn', 'tnx', ... (exhaustive list in i18n.inc).
> 
> Also FOREACH is probably not the only way to "hide" these macros (for
> instance [% t = ... %] or [% WHILE (t = ...) %] probably does the same thing)
> 
> Another solution could be to remove i18n.inc, forcing us to use [%
> I18N.t("...") %] which is unlikely to conflict with other variables.
> 
> Or another (but hypothetical as I'm not sure it works): redefine these
> functions as filters [% "..." | t %] (I believe filters don't conflict with
> variable names ?)

These are all good points, although I'm not sure how feasible or cost-efficient
would be to turn all occurrences of [% t('translate this') | html %]
into
[% 'translate this' | t | html %]
Running the following:
git grep "\bt(" /kohadevbox/koha/koha-tmpl/intranet-tmpl/prog/ | wc -l
Results in 1701 and that's likely not all of it.
I'm assuming we can chain filters in .tt although I'm not 100% sure.
If my above interpretation of what's being suggested is incorrect then please
ignore.

git grep "WHILE"
We can see that WHILE is hardly ever used and although it'd be great to ensure
it doesn't happen in the future, I'm not sure it's worth the effort at this
point to address for this possibility too.

git grep "\[% t="
git grep "\[% t ="
Don't return anything.

Thinking of cost-efficiency here, I think that only considering "FOREACH t IN"
in our qa script for now would be a good step in the right direction.
Addressing all possible macro names from i18n may also be an option but I'm not
sure how far the rabbit hole goes.
As far as I can tell this issue does not happen anywhere else in Koha at the
moment. Even in files like additem.tt, I think because all t("translatable
string") calls happen at the start of the file, before any of the "FOREACH t in
templates" occurrences that come further down.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list