I think you need to specify in the header of your po file the number
of plural forms for your language.

http://www.gnu.org/software/gettext/manual/html_chapter/gettext_10.html#PO-Files
(at the end of chapter)
http://www.gnu.org/software/gettext/manual/html_chapter/gettext_10.html#Plural-forms
(the whole chapter)

I've not tested this on CakePHP.


On Sat, Mar 29, 2008 at 2:36 PM, Claudinei <[EMAIL PROTECTED]> wrote:
>
>  Hi,
>
>  I'm trying to understand how I18n works on Cake and after a lot of
>  tests and reads of the I18n and Basic classes source I've found
>  something.
>
>  I'm not really sure if my problem is with class Basic "__n" function
>  or class I18n "translate" function, or even maybe I'm
>  missunderstanding those functions purporses.
>  Anyway I have this scenario:
>
>  A post description with a comments link where the text for the
>  comments link should change according with the number of comments:
>  "Leave a comment"
>  "Show Comment"
>  "Show Comments (xx)" (where xx is the number of comments)
>
>  I think "__n" function should result:
>  a "singular" string for the no comments case
>  a "plural" string for the just one comment case (what works right now)
>  and a plural string for more than 1 comment case
>
>  But as the 1.2 beta release if you do call I18n::translate with a
>  singular msgid different than plural msgid and if the singular msgid
>  exists, it will be returned, regardless of the number of comments.
>  So if I really want to use I18n::translate or "__n" function from
>  Basic class I will have to do something like "__n($plural_msgid,
>  $plural_msgid)" with the plural msgid twice, as for the singular and
>  plural args.
>
>  As first I thought the solution could be simple as editing Basic class
>  and adding the follow code after the "App::import" into "__n"
>  function:
>  if($count == 0)
>  {
>  $trans = I18n::translate($singular);
>  }
>  else
>  {
>  $trans = I18n::translate($singular, $plural, null, 5, $count);
>  }
>
>  if($return === false)
>  {
>  echo $trans;
>  }
>  else
>  {
>  return $trans;
>  }
>
>  But after that, "__n" function still resulting the singular msgid.
>  To solve the remaining problem, I've just changed I18n::translate
>  function a bit, changing this follow "if":
>
>  if (($trans = $_this->__domains[$_this->category][$domain][$singular])
>  || ($pli) && ($trans = $_this->__domains[$_this->category][$domain]
>  [$plural]))
>
>  to:
>
>  if (u$trans = $_this->__domains[$_this->category][$domain][$plural])
>  || ($trans = $_this->__domains[$_this->category][$domain][$singular]))
>
>
>  Now I can call "__n" in this way:
>  printf(__n('add_comment', 'comments', $n, true), $n);  #(where $n is
>  the number of comments)
>
>  And I18n class will return the correct string from default.po:
>  msgid "add_comment"
>  msgstr "Leave a comment"
>
>  msgid "comments"
>  msgid_plural "comments"
>  msgstr[0] "Show Comment"
>  msgstr[1] "Show Comments (%d)"
>
>
>  Is there anyone having the some problem? Is there another clean
>  solution without having to change both Basic and I18n classes?
>  Or am I trying to do something in the wrong place?
>
>  Thanks in any advice.
>
>  Claudinei
>
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to