1.1.13 • Published 2 months ago
@jswork/react-ant-i18n v1.1.13
react-ant-i18n
I18n for antd.
installation
npm install -S @jswork/react-ant-i18n
usage
import css
@import "~@jswork/react-ant-i18n/dist/style.css"; // or use sass @import "~@jswork/react-ant-i18n/dist/style.scss"; // customize your styles: $react-ant-i18n-options: ()
import js
import React, { useState } from 'react'; import { useIntl } from '@jswork/react-ant-i18n'; import styled from 'styled-components'; import { Select, Space, Table, DatePicker, TimePicker, Avatar, Button, Modal } from 'antd'; import nx from '@jswork/next'; const Container = styled.div` .ant-avatar { margin: 10px 0; } `; const items = [ { value: 'en-US', label: 'English' }, { value: 'zh-CN', label: '中文' } ]; export default () => { const { t, i18n } = useIntl(); const [visible, setVisible] = useState<boolean>(false); // inject as global for debug nx.t = t; nx.i18n = i18n; const img = i18n.language === 'zh-CN' ? '5' : '1'; return ( <Container> <div className="App"> <header className="App-header"> <Space> <Avatar src={`https://randomuser.me/api/portraits/lego/${img}.jpg`} size={120} /> <Select value={i18n.language} style={{ width: 120 }} onChange={(value) => i18n.changeLanguage(value)} options={items} /> </Space> <Space direction="vertical"> <h1 style={{ color: '#fff' }}>{t('key')}</h1> <p dangerouslySetInnerHTML={{ __html: t('desc', { interpolation: { escapeValue: false } }) }} /> <Table style={{ width: 600 }} dataSource={[]} /> <Space> {/* @ts-ignore */} <DatePicker /> <TimePicker /> <Button type="primary" onClick={() => setVisible(true)}> {t('open-a-modal')} </Button> </Space> </Space> </header> <Modal open={visible} onOk={() => setVisible(false)} onCancel={() => setVisible(false)}> {t('mtxt')} </Modal> </div> </Container> ); };
preview
license
Code released under the MIT license.
1.1.13
2 months ago
1.1.1
7 months ago
1.0.19
9 months ago
1.0.18
9 months ago
1.0.17
9 months ago
1.0.16
9 months ago
1.1.9
7 months ago
1.1.8
7 months ago
1.0.9
9 months ago
1.1.7
7 months ago
1.0.8
9 months ago
1.1.6
7 months ago
1.0.7
9 months ago
1.1.5
7 months ago
1.0.6
9 months ago
1.1.4
7 months ago
1.1.3
7 months ago
1.1.2
7 months ago
1.1.12
7 months ago
1.0.22
7 months ago
1.1.11
7 months ago
1.0.21
7 months ago
1.1.10
7 months ago
1.0.20
8 months ago
1.0.26
7 months ago
1.0.25
7 months ago
1.0.24
7 months ago
1.0.23
7 months ago
1.0.29
7 months ago
1.0.28
7 months ago
1.0.27
7 months ago
1.0.11
9 months ago
1.0.10
9 months ago
1.0.31
7 months ago
1.0.30
7 months ago
1.0.15
9 months ago
1.0.14
9 months ago
1.0.13
9 months ago
1.0.12
9 months ago
1.0.5
1 year ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago