FormattedNumber
小数の処理に使用します。例えば:
it('formats numbers with decimal separators', () => {
const el = <FormattedNumber value={0.1} minimumFractionDigits={2} />;
renderer.render(el, intlProvider.getChildContext());
expect(renderer.getRenderOutput()).toEqualJSX(
<span>0.10</span>
);
});
複数形には異なる値を使用します。
it('pluralizes labels in strings', () => {
const el = (
<FormattedMessage
id="num_emails"
defaultMessage="You have 1.{teaspoons, plural, one {# teaspoons} other {# teaspoons}}."
values={{
teaspoons: 2,
}}
/>
);
および単数形:
it('pluralizes labels in strings', () => {
const el = (
<FormattedMessage
id="num_emails"
defaultMessage="You have 2.{teaspoons, plural, one {# teaspoons} other {# teaspoons}}."
values={{
teaspoons: 1,
}}
/>
);
参考文献