2 Nov 2009 12:50
Re: Chaining i18n:translate
On 31-10-2009 at 18:49:16 Daniel Trebbien <dtrebbien@...> wrote: > A long time ago I modified two, PHPTAL 1.1.16 library files to allow > expression chaining in i18n:translate. This allowed, for example: > <div class="error" i18n:translate="error | string:Invalid username or > password">Login error</div> > which means: translate the value of the error variable if that > variable is set, or translate the string "Invalid username or > password". The patches worked really well for PHPTAL 1.1.16, and were > quite useful is certain scenarios, so I decided to try and migrate the > changes to 1.2.0. > > Attached are unified diffs (from v. 1.2.0) for the two files needing > modification: `PHPTAL/Php/Attribute/I18N/Translate.php` and > `PHPTAL/Php/Attribute/TAL/Content.php`. Basically, I tried to make the > same changes as before, but I noticed the new escape vs. stringify > feature, so I additionally incorporated changes in support of that. Thanks! I've had to fix one thing: it broke support for i18n:name. Other than that it works OK and will be part of next release. > (Is it just me, or shouldn't the second argument to > TranslationService::translate be deprecated?) Unfortunately not. The problem is that interpolated variables may need to contain XHTML markup.(Continue reading)
RSS Feed