PHP PECL 扩展 intl 给出瑞典语序数的乱码结果
我正在使用 PECL intl 模块来本地化 PHP 项目中的日期和数字。在我使用的所有其他语言 (40) 中,本地化序数效果很好。然而,在瑞典语中,我得到了奇怪的输出。它似乎是用于生成序数的模板常量。
$fnf = new NumberFormatter('sv_FI', NumberFormatter::ORDINAL);
echo $fnf->format(1);
两者
$snf = new NumberFormatter('sv_SE', NumberFormatter::ORDINAL);
echo $snf->format(1);
都返回 1:e%digits-ordinal-neutre:0: 1:a
与 1st
或 1er
之类的内容。
除了错误之外,我唯一的猜测是我缺少一些额外的参数,例如相关动词的性别。
I'm using the PECL intl module to localize dates and numbers in a PHP project. In all other languages I'm using (40), localizing ordinal numbers works fine. In Swedish, however, I get strange output. It appears to be the template constants used to generate the ordinals.
$fnf = new NumberFormatter('sv_FI', NumberFormatter::ORDINAL);
echo $fnf->format(1);
and
$snf = new NumberFormatter('sv_SE', NumberFormatter::ORDINAL);
echo $snf->format(1);
Both return 1:e%digits-ordinal-neutre:0: 1:a
vs. something like 1st
or 1er
.
My only guess, other than a bug, is that I'm missing some additional argument such as the gender of an associated verb.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您输出基于规则的数字格式化程序规则
$fnf->getPattern()
:您可以看到私有规则集
dord-mascabbrev
只有一条给出该值的规则:您将在 1 之后输出,就像您在问题中所描述的那样。
这不是 PECL INTL 中的错误,但作为 ICU 库一部分的基本规则格式错误 (那条规则)。大约三年前,sv 数字格式化规则针对缺少分号的情况进行了修复,看起来好像漏掉了一行。
这些规则从 Unicode 联盟的 CLDR(公共区域设置数据存储库)纳入 ICU。我在那里打开了一个 bug 报告,因为除非在 CLDR 中修复了这个问题,然后将其放入ICU,它不能与 PHP INTL 扩展一起使用。
另一种方法可能是手动修补 ICU 库(版本 4.8),然后针对修补的库构建 PECL 包。
If you output the rule based number formatters rules
$fnf->getPattern()
:You can see that the private rule set
dord-mascabbrev
only has one rule giving that value:Which you will have then output after your 1, like you describe in your question.
This is not a bug in PECL INTL, but the underlying rule is malformatted which is part of the ICU Libraries (that rule there). About three years ago the sv number formatter rules were fixed for missing semicolons, it looks like that one line slipped through.
These rules are taken into ICU from the CLDR (Common Locale Data Repository) at the Unicode Consortium. I opened a bug report there, because unless this is fixed in CLDR, and then put into ICU, it can't work with the PHP INTL extension.
The alternative might be to manually patch the ICU libraries (version 4.8) and then build the PECL package against your patched libraries.