import { connect } from 'react-redux'
import styles from './Modal.scss'
import actions from 'actions'
+import {withNamespaces} from 'react-i18next'
class Modal extends React.Component {
render() {
isShowing,
body,
acceptAction,
- cancelAction
+ cancelAction,
+ t
} = this.props
- const lang = this.props.lang
if (!isShowing) return null
{
boxStyle &&
<div className={styles.title}>
- <p>{ lang === 'zh' ? '命令行' : 'Console'}</p>
+ <p>{ t('console.title')}</p>
<button className={`btn ${styles.close}`} onClick={accept}>X</button>
</div>
}
{body}
{!noCloseBtn && <button className={`btn btn-${this.props.options.danger ? 'danger' : 'primary'} ${styles.accept}`} onClick={accept}>
- { lang === 'zh' ? '关闭' : 'OK' }</button>}
+ { t('form.ok') }</button>}
{!noCloseBtn && cancel && <button className={`btn btn-link ${styles.cancel}`} onClick={cancel}>Cancel</button>}
</div>
</div>
acceptAction: state.app.modal.accept,
cancelAction: state.app.modal.cancel,
options: state.app.modal.options,
- lang: state.core.lang
})
// NOTE: ommitting a function for `mapDispatchToProps` passes `dispatch` as a
// prop to the component
-export default connect(mapStateToProps)(Modal)
+export default connect(mapStateToProps)(withNamespaces('translations')(Modal))
this.props.showModal(
<ConsoleSection
cmd={this.props.cmd}
- lang={this.props.core.lang}
/>
)
}
import { BaseList, TableList } from 'features/shared/components'
import ListItem from './ListItem'
+import {withNamespaces} from 'react-i18next'
const type = 'key'
class KeyList extends BaseList.ItemList {
}
-const mapStateToProps = (state) => {
- let titles
- if(state.core.lang === 'zh'){
- titles = ['别名','主公钥']
- }else{
- titles = ['Alias', 'xpub']
- }
-
+const mapStateToProps = (state, props) => {
return {
...BaseList.mapStateToProps(type, ListItem, {
skipQuery: true,
label: 'Keys',
wrapperComponent: TableList,
wrapperProps: {
- titles: titles
+ titles: props.t('key.formTitle', { returnObjects: true })
}
})(state)
}
}
-export default BaseList.connect(
+export default withNamespaces('translations') (BaseList.connect(
mapStateToProps,
BaseList.mapDispatchToProps(type),
KeyList
-)
+))
import commandList from './command.json'
import ListItem from './ListItem/ListItem'
import disableAutocomplete from 'utility/disableAutocomplete'
+import {withNamespaces, Trans} from 'react-i18next'
class ConsoleSection extends React.Component {
constructor(props) {
}
render() {
- const lang = this.props.lang
+ const t = this.props.t
let taskList = this.state.data.map(function(listItem) {
return (
<ListItem
className={styles.reactConsoleContainer}
ref={(el) => { this.messagesContainer = el }}
>
- <p>
- {lang === 'zh' ?
- '欢迎来到Bytom Core API 命令行。':
- 'Welcome to the Bytom Core API console.'}<br/>
- {lang === 'zh' ? '输入':'Type' }<code>help</code> {lang === 'zh' ?'查看所有可用命令行。':'for an overview of available commands.'}
- </p>
+ <Trans i18nKey='console.message' parent='p'>
+ Welcome to the Bytom Core API console.<br/> Type <code>help</code> for an overview of available commands
+ </Trans>
<p className='text-danger'>
<strong>
- {lang === 'zh' ? '注意' : 'WARNING'}:
- </strong> {lang === 'zh' ?
- '骗子可能会让你在此输入命令,以盗取你的钱包内容。 如果你没有了解命令所带来的后果,请不要在此输入命令。':
- 'Scammers have been active, telling users to type commands here, stealing their wallet contents. Do not use this console without fully understanding the ramification of a command.'}
+ {t('console.warning')}:
+ </strong>
+ {t('console.warningMessage')}
</p>
{taskList}
</div>
type='text'
autoFocus='autofocus'
onKeyDown={(event) => this.keyDownEvent(event)}
- placeholder={ lang === 'zh' ? '输入 \"help\" 查看所有可用的命令' : 'Enter "help" for an overview of available commands' } />
+ placeholder={t('console.placeholder')} />
</span>
<button type='submit' className={'btn btn-primary'} tabIndex='-1'>
- > { lang === 'zh' ? '输入' : 'Enter' }
+ > { t('form.enter') }
</button>
</form>
</div>
}
}
-export default ConsoleSection
\ No newline at end of file
+export default withNamespaces('translations') (ConsoleSection)
\ No newline at end of file
},
react: {
- wait: true
+ wait: true,
}
})
"index":"Index",
"keys": "Keys",
"key": "Key",
- "selectPlaceholder": "Select one..."
+ "selectPlaceholder": "Select one...",
+ "enter":"Enter",
+ "ok":"OK"
},
"xpub":{
"methodOptions" : {
"highestBlock":"Highest Block",
"networkId":"Network Id",
"coreStatus":"Core Status"
+ },
+ "console":{
+ "title":"Console",
+ "message":"Welcome to the Bytom Core API console.<1/> Type <2>help</2> for an overview of available commands",
+ "warning":"WARNING",
+ "warningMessage":"Scammers have been active, telling users to type commands here, stealing their wallet contents. Do not use this console without fully understanding the ramification of a command.",
+ "placeholder":"Enter \"help\" for an overview of available commands"
+ },
+ "key":{
+ "formTitle":["Alias", "xpub"]
+
}
}
\ No newline at end of file
"index":"索引",
"keys": "密钥数",
"key": "密钥",
- "selectPlaceholder": "请选择..."
+ "selectPlaceholder": "请选择...",
+ "enter":"输入",
+ "ok":"关闭"
},
"xpub":{
"methodOptions" : {
"highestBlock":"最高高度",
"networkId":"网络ID",
"coreStatus":"核心状态"
+ },
+ "console":{
+ "title":"命令行",
+ "message":"欢迎来到Bytom Core API 命令行。<1/> 输入<2>help</2> 查看所有可用命令行。",
+ "warning":"注意",
+ "warningMessage":"骗子可能会让你在此输入命令,以盗取你的钱包内容。 如果你没有了解命令所带来的后果,请不要在此输入命令。",
+ "placeholder":"输入 \"help\" 查看所有可用的命令"
+ },
+ "key":{
+ "formTitle":["别名","主公钥"]
}
}
\ No newline at end of file