Thank you, Ryan. I know the "problem" of the 3 different "the" in german. I'm from Switzerland... ;-)
Anyway, there are some workarounds you can take... e.g. instead of using "Der/die/das Buch wurde gespeichert." you can simply use "Buch wurde gespeichert.". Not that very nice, but all correct. But that's only german - who knows what problems one is faced when a website needs to be translated to many other languages? Anyway, for my purposes the workaround above works out... On Thu, Jan 27, 2011 at 12:57 PM, Ryan Schmidt <[email protected]> wrote: > On Jan 27, 2011, at 03:48, psybear83 wrote: > >> 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? > > I would agree with what you said. The way the localization functions are used > in /cake/libs/controller/scaffold.php in CakePHP 1.3.6 seems all wrong. > > Since CakePHP 2.0 has changed (or will change) the usage of __() to > incorporate the usage of sprintf(), all calls to __() have already been (or > will hopefully soon be) touched in the CakePHP source. I checked scaffold.php > in the CakePHP 2.0 branch and this seems to be fixed there: > > https://github.com/cakephp/cakephp/blob/2.0/cake/libs/controller/scaffold.php > > However, I would further point out that even if the functions were called in > the correct order as you suggested above, a string like 'The %1$s' cannot be > accurately translated. Consider the language German, where there are three > different words for "the" depending on the gender of the noun (and it changes > again depending on where it's used in the sentence). Any time you have a noun > substituted into a string, you're going to have this problem, so that affects > a great many of the strings in scaffold.php that are marked for translation. > Strings like 'Invalid %s', 'The %1$s has been %2$s', 'There was an error > deleting the %1$s with id: %2$d' -- these all cannot be translated correctly. > > > > -- > 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 > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php > -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
