Symfony i18n fromat_number_choice不能正常工作

时间:2013-02-01 14:06:25

标签: internationalization symfony-1.4

我在Symfony 1.4中使用以下代码format_number_choice

<?php echo format_number_choice(
        '[0]You do not have any remaining invites.|[1]You have one invite.|(1,+Inf]You have %1% invites.', array('%1%' => $users->getInvitatii()), $users->getInvitatii(), 'nrchoice') ?>

翻译字符串如下所示:

<trans-unit id="2" approved="yes">
        <source>[0]You do not have any remaining invites.|[1]You have one invite.|(1,+Inf]You have %1% invites.</source>
        <target state="translated">[0]Nu mai aveți nicio invitație|[1]Mai aveți o invitație|{n: n % 100 < 20} Mai aveți %1% invitații.|{n: n % 100 > 20} Mai aveți %1% de invitații.</target>
</trans-unit>

在罗马尼亚语中,有两种复数类型:number%100 < 20number%100 >= 20。唯一的问题是我的字符串没有翻译,我猜我的语法有错误,但我无法弄清楚问题出在哪里。我在Symfony 1.4文档中找到了这种语法。

1 个答案:

答案 0 :(得分:0)

你可以尝试一下:

php代码:

<?php echo format_number_choice(
  '[0]You do not have any remaining invites.|[1]You have one invite|{n: n % 100 < 20} You have %1% invites.|{n: n % 100 > 20} You have %1% invites.', 
  array('%1%' => $users->getInvitatii()), $users->getInvitatii(), 'nrchoice')
?>

在翻译文件中:

<trans-unit id="2" approved="yes">
  <source>[0]You do not have any remaining invites.|[1]You have one invite|{n: n % 100 < 20} You have %1% invites.|{n: n % 100 > 20} You have %1% invites.</source>
  <target state="translated">[0]Nu mai aveți nicio invitație|[1]Mai aveți o invitație|{n: n % 100 < 20} Mai aveți %1% invitații.|{n: n % 100 > 20} Mai aveți %1% de invitații.</target>
</trans-unit>