Thursday, January 27, 2011

Translating the scaffold flashes - it nearly can't be done the way they are formatted?! --psybear

Hey everybody

I want to translate the flash messages of $scaffold (I know, $scaffold
shouldn't be used, don't tell me this ;-) ).

I looked through the code to find the msg-strings, and for deletion,
they look like this:

$message = __(
sprintf('The %1$s with id: %2$d has been deleted.',
Inflector::humanize($this->modelClass), $id),
true
);

Now, this seems very unthoughtful to me, because the sprintf() results
in strings like

The Application with id: 1 has been deleted.
The Application with id: 2 has been deleted.
The Application with id: 3 has been deleted.

which are absolutely not prepared for being translation! IMO only the
sprintf-string should be translated, and THEN the sprintf should be
run OVER this string!


$message = sprintf(
__('The %1$s with id: %2$d has been deleted.', true),
Inflector::humanize($this->modelClass), $id
);

This way, only "The %1$s with id: %2$d has been deleted." must be
translated. Or even better (to also translate the model):

$message = sprintf(
__('The %1$s with id: %2$d has been deleted.', true),
__(Inflector::humanize($this->modelClass), true), $id
);

Do I miss an important point somewhere? Or why isn't it realized like
this?

Thanks
Josh

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: