当值是"0"时,Symfony transchoice无法选择翻译.和语言“斯洛文尼亚语" [英] Symfony transchoice can't choose a translation when value is "0" and language "slovenian"

查看:95
本文介绍了当值是"0"时,Symfony transchoice无法选择翻译.和语言“斯洛文尼亚语"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'permission.label'|transchoice(0, {}, 'someBundle')

使用上述代码,当启用"sl"作为区域设置时,出现以下错误:

With above code I'm getting the following error when enabling "sl" as locale:

无法选择带有语言环境的"Dovoljenje | Dovoljenja"的翻译 "sl"代表值"0".仔细检查此翻译是否正确 多个选项(例如有一个苹果|有%count%个苹果").

Unable to choose a translation for "Dovoljenje|Dovoljenja" with locale "sl" for value "0". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %count% apples").

在其他语言中(英语,德语,法语,意大利语,以及另外10种语言),我对此没有任何问题.只有斯洛文尼亚人打破了我的完整申请,因为transchoice无法选择翻译.

In other languages (english, german, french, italian, +10 more) I don't have any issues with this. Only slovenian breaks my complete application bc transchoice is unable to pick a translation.

例如,"Permission | Permissions"在语言环境"en"和值"0"下可以正常工作.但是在"sl"中,它将引发以上错误.

For example "Permission|Permissions" works fine with locale "en" and value "0". But in "sl" it will throw the above error.

有什么想法吗?

谢谢!

推荐答案

您的字符串"Dovoljenje|Dovoljenja"仅具有两个选择,就像许多使用一个"和其他"形式的语言一样.

Your string "Dovoljenje|Dovoljenja" only has two choices like many languages that use the forms "one" and "other".

斯洛文尼亚语的形式更多,这就是为什么您的其他语言有效,而斯洛文尼亚语则无效的原因.

Slovenian has more forms than that, which is why your other languages work, but Slovenian doesn't.

查看将多个规则烘焙到翻译组件中,斯洛文尼亚的等式如下:

Looking at the plural rules baked into the Translation component, the equation for Slovenian is as follows:

(1 == $number % 100) ? 0 : ((2 == $number % 100) ? 1 : 
(((3 == $number % 100) || (4 == $number % 100)) ? 2 : 3));

这表示存在四种形式:一个",两个",很少"和其他".替换$number=0将返回最后的其他"选项作为偏移量[3],这在您的字符串中不存在.

This indicates that there are four forms: "one" "two" "few" and "other". Substituting $number=0 will return the final "other"" option as offset [3]which does not exist in your string.

我不会说斯洛文尼亚语,但是如果两个",很少"和其他"都可以具有相同的翻译,则将您的字符串设置为"Dovoljenje|Dovoljenja|Dovoljenja|Dovoljenja",错误就会消失.

I don't speak Slovenian, but if "two" "few" and "other" can all have the same translation then set your string to "Dovoljenje|Dovoljenja|Dovoljenja|Dovoljenja" and the error will go away.

这篇关于当值是"0"时,Symfony transchoice无法选择翻译.和语言“斯洛文尼亚语"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆