2013-02-01 79 views
1

我有用途format_number_choice下面的代碼中的Symfony 1.4:Symfony的國際化fromat_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> 

在羅馬尼亞,有是2種複數:number%100 < 20number%100 >= 20。唯一的問題是我的字符串沒有被翻譯,我猜我的語法有錯誤,但我無法弄清楚問題出在哪裏。我在Symfony 1.4文檔中找到了這個語法。

+0

你得到一個錯誤?你有沒有試圖用2個複數的英文寫源碼,而不是保留默認選擇? – j0k

+0

好吧,這是一個有趣的事實:如果我直接在format_number_choice中使用該語法,它會很好地工作。它只是不想處理翻譯的字符串。 – Daniel

+0

@Daniel嘗試編碼「>」爲「>」,「<」爲「<」,因爲這些在xml中無效。 – 1ed

回答

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> 
+0

結果相同。它只顯示英文文本。 – Daniel

+0

你的xliff文件中的節點'file'裏面有什麼? – j0k

相關問題