What does “__n()” do in cakephp?
While working on a multilingual app using Cakephp I was reminding myself of the best way to add variables to localised strings in cakePHP and I cam across the __n() function which amazingly I had never used before.
The __n() function is described in the API documentation as:
/** * Returns correct plural form of message identified by $singular and $plural for count $count. * Some languages have more than one form for plural messages dependent on the count. */ function __n($singular, $plural, $count, $return = false)
Thus it is simply a means to overcome the common problem of pluralising the text display when a variable quantity is specified. Powerful stuff. When used in combination with variables in localised strings in CakePHP it offers just about everything you need to provide a coherent, localised version of your site.
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

[...] Source: http://www.honk.com.au/index.php/2009/10/09/what-does-__n-do-in-cakephp/ [...]