React-Intl:消息未在 Safari 中格式化
React-Intl: Message not formatting in Safari
我有以下翻译:
{count, number} {count, plural, one {Kundenbewertung} other {Kundenbewertungen}}
在 Chrome 中它显示 23 Kundenbewertungen
很好,但在 Safari 中它显示翻译字符串并抛出错误
Error formatting message: "pdp:product-title:ratings" for locale: "de"
Cannot format message: "pdp:product-title:ratings", using message source as fallback.
在我的 React 组件中,代码如下:
<FormattedMessage
id="pdp:product-title:ratings"
values={{ count: product.metadata.rating.count }}
/>
我完全迷路了,因为它在 Chrome 中按预期工作。我使用的语法正确吗?
原因是 Intl.PluralRules it not available on Safari. Just use this polyfill 并且一切都应该按预期工作。
这是一个更好的 polyfill,由 MDN 推荐并被 polyfill.io 使用:https://formatjs.io/docs/polyfills/intl-pluralrules/
我有以下翻译:
{count, number} {count, plural, one {Kundenbewertung} other {Kundenbewertungen}}
在 Chrome 中它显示 23 Kundenbewertungen
很好,但在 Safari 中它显示翻译字符串并抛出错误
Error formatting message: "pdp:product-title:ratings" for locale: "de"
Cannot format message: "pdp:product-title:ratings", using message source as fallback.
在我的 React 组件中,代码如下:
<FormattedMessage
id="pdp:product-title:ratings"
values={{ count: product.metadata.rating.count }}
/>
我完全迷路了,因为它在 Chrome 中按预期工作。我使用的语法正确吗?
原因是 Intl.PluralRules it not available on Safari. Just use this polyfill 并且一切都应该按预期工作。
这是一个更好的 polyfill,由 MDN 推荐并被 polyfill.io 使用:https://formatjs.io/docs/polyfills/intl-pluralrules/