/** * @title withVar */ import React from 'react' import { Input } from '@alicloud/console-components' import { reactIntlFactory } from '@alicloud/console-components-intl' const intl = reactIntlFactory() export const messages = { 'text.with.vars': 'This is a { type } text.', 'text.with.condition.vars': ` This is a { type, select, simple { SIMPLE } vars { VARIABLES-INCLUDES } cond { CONDITIONAL-VARIABLES-INCLUDES } } text.`, 'text.with.wrong.condition.vars': ` This is {region, select, cn-huabei {华北} cn-qingdao {青岛} other {{region}} }.`, 'text.with.date': 'Current datetime is { current, date }', 'text.with.number.and.plural': `You have { count, plural, =0 { no messages } =1 { only one message } =2 { two messages } other { # messages } }`, } intl.set({ messages, locale: 'en-US', }) const App: React.FC<{}> = () => { return (
{intl('text.with.vars', { type: 'variables-includes' })}
{intl('text.with.vars', { type: component-variables-includes, })}
{intl('text.with.condition.vars', { type: 'simple' })}
{intl('text.with.condition.vars', { type: 'vars' })}
{intl('text.with.condition.vars', { type: 'cond' })}
{intl('text.with.wrong.condition.vars', { region: 'cn-huabei' })}
{intl('text.with.date', { current: new Date() })}
{intl('text.with.number.and.plural', { count: 0 })}
{intl('text.with.number.and.plural', { count: 1 })}
{intl('text.with.number.and.plural', { count: 2 })}
{intl('text.with.number.and.plural', { count: 100 })}
{intl('text.with.number.and.plural', { count: 1000 })}
{intl
{intl