php – NumberFormatter :: SPELLOUT spellout-ordinal in Russi
这段代码适用于英语,西班牙语和德语的ordninal数字,但俄语或意大利语的号码不起作用.
‘ru-RU’,’it-IT’也行不通 我用俄语获得2 – > два(这是基数),但我想要序数,这将是2 – > второй. 我在意大利语中得到2 – >到期(这是基数),这将是2 – > SECONDO. 更新: 我找到了一个法语,西班牙语,德语和其他语言的解决方案: maskuline序数:%spellout-ordinal-maskuline 女性序数:%spellout-ordinal-feminine 俄语和意大利语版本不起作用,我已经尝试使用-maskuline / -feminine $ru_ordinal = new NumberFormatter('ru',NumberFormatter::SPELLOUT); $ru_ordinal->setTextAttribute(NumberFormatter::DEFAULT_RULESET,"%spellout-ordinal");
NumberFormatter正在使用ICU格式.
你可以在这里查看:http://saxonica.com/html/documentation/extensibility/config-extend/localizing/ICU-numbering-dates/ICU-numbering.html …俄语(ru)有以下格式: > spellout-cardinal-feminine(scf) ……和意大利语(它): > spellout-cardinal-feminine(scf) 这就是为什么你将无法为(ru)和以下代码设置序数格式的原因: $nFormat = new NumberFormatter('it',NumberFormatter::SPELLOUT); $nFormat->setTextAttribute(NumberFormatter::DEFAULT_RULESET,"%spellout-ordinal-feminine"); var_dump($nFormat->format(42)); 将打印: string 'quaranta-duesima' (length=17) 像你(可能)想要的. 编辑: 有关二手格式的信息,参考ICU:http://php.net/manual/en/numberformatter.create.php 使用PHP 5.4.x和ICU版本=>进行测试51.2; ICU数据版本=> 51.2. $php -i | grep ICU 检查您的ICU版本. 对于最新的ICU版本,您应该可以安装/更新php-intl软件包:http://php.net/manual/en/intl.installation.php 编辑2: 我已经为NumberFormatter创建了扩展(到目前为止已经有了抛光序数).欢迎提供其他语言:https://github.com/arius86/number-formatter (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |