2008年9月18日星期四

[fw-mvc] Re: Correct way to create a _()-ViewHelper for translations

The WRS schrieb:
> I opted for a global function which is defined as part of my bootstrap file
> ...
> function _($messageId = null) {

This would result in 'Fatal error: Cannot redeclare _() ...' on gettext-
enabled PHP installations, so it would not be possible (at least not
without namespaces ;-) ).

As most of my projects are fully internationalized (I'm living in a
province of Italy where most people speak German for historical
reasons) I would also prefer such a solution - but _() is not possibly
(at least not yet).

I've seen some projects using __() as a way out of this dilemma, what
other approaches could we use?

In my opinion

<?= $this->_('Hello') ?>

vs

<?= __('Hello') ?>

is probably a rather religious than technical problem :p I think most
people (those using translations in real life!) would probably agree
on the fact that

<?= $this->translate('Hello') ?>

is the worst-looking one :p

Regards,
Thomas

没有评论: