import Tutorial from 'features/tutorial/components/Tutorial'
import TutorialHeader from 'features/tutorial/components/TutorialHeader/TutorialHeader'
import { Navigation, SecondaryNavigation } from '../'
-import { withNamespaces, Trans } from 'react-i18next'
+import { withNamespaces } from 'react-i18next'
class Main extends React.Component {
render() {
let logo = require('images/logo-bytom-white.svg')
- const { i18n ,lng, version } = this.props
+ const { t, i18n , version } = this.props
const changeLanguage = (lng) => {
i18n.changeLanguage(lng)
className={styles.languages}
noCaret
>
- {lng === 'zh' ? '中' : 'EN'}
+ {t('language')}
</Dropdown.Toggle>
<Dropdown.Menu
className={styles.languagesMenu}
<div className={styles.version}>
<span>
- {lng==='zh'?'版本号':'Version'}: {version}
+ {t('commonWords.version')}: {version}
</span>
</div>
(state) => ({
canLogOut: state.core.requireClientToken,
version:state.core.version,
- lang: state.core.lang,
connected: true,
showDropwdown: state.app.dropdownState == 'open',
}),
(dispatch) => ({
toggleDropdown: () => dispatch(actions.app.toggleDropdown),
closeDropdown: () => dispatch(actions.app.closeDropdown),
- setLang: (event) => {
- dispatch({
- type: 'UPDATE_CORE_LANGUAGE',
- lang: event
- })
- }
})
)(Main))
RawJsonButton,
} from 'features/shared/components'
import componentClassNames from 'utility/componentClassNames'
+import { withNamespaces } from 'react-i18next'
class AssetShow extends BaseShow {
render() {
- const item = this.props.item
- const lang = this.props.lang
+ const { item, t } = this.props
let view
if (item) {
const title = <span>
- { lang === 'zh' ? '资产' :'Asset ' }
+ { t('asset.asset') }
<code>{item.alias ? item.alias :item.id}</code>
</span>
<KeyValueTable
id={item.id}
object='asset'
- title={ lang === 'zh' ? '详情' : 'Details' }
+ title={t('form.detail')}
actions={[
// <button key='show-circulation' className='btn btn-link' onClick={this.props.showCirculation.bind(this, item)}>
// Circulation
]}
items={[
{label: 'ID', value: item.id},
- {label: ( lang === 'zh' ? '别名' : 'Alias' ), value: item.alias, editUrl: item.alias === 'BTM' ? null : `/assets/${item.id}/alias`},
- {label: ( lang === 'zh' ? '定义' : 'Definition'), value: item.definition},
- {label: ( lang === 'zh' ? '扩展公钥数' : 'xpubs' ), value: (item.xpubs || []).length},
- {label: ( lang === 'zh' ? '签名数' : 'Quorum' ), value: item.quorum},
+ {label: t('form.alias'), value: item.alias, editUrl: item.alias === 'BTM' ? null : `/assets/${item.id}/alias`},
+ {label: t('form.definition'), value: item.definition},
+ {label: t('form.xpubs'), value: (item.xpubs || []).length},
+ {label: t('form.quorum'), value: item.quorum},
]}
- lang={lang}
/>
{(item.xpubs || []).map((key, index) =>
<KeyValueTable
key={index}
- title={lang === 'zh' ? `扩展公钥 ${index + 1}` :`xpub ${index + 1}`}
+ title={t('asset.xpubs', {id: index + 1})}
items={[
- {label: ( lang === 'zh' ? '索引' : 'Index' ), value: index},
- {label: ( lang === 'zh' ? '资产公钥' : 'Asset Pubkey') , value: key},
+ {label: t('form.index') , value: index},
+ {label: t('asset.assetPub') , value: key},
]}
- lang={lang}
/>
)}
</PageContent>
const mapStateToProps = (state, ownProps) => ({
item: state.asset.items[ownProps.params.id],
- lang: state.core.lang
})
const mapDispatchToProps = ( dispatch ) => ({
})
-export default connect(
+export default withNamespaces('translations') ( connect(
mapStateToProps,
mapDispatchToProps
-)(AssetShow)
+)(AssetShow))
import React from 'react'
import { BaseUpdate, FormContainer, FormSection, NotFound, TextField } from 'features/shared/components'
import { reduxForm } from 'redux-form'
+import {withNamespaces} from 'react-i18next'
class Form extends React.Component {
constructor(props) {
}
render() {
- const lang = this.props.lang
if (this.state.notFound) {
- return <NotFound lang={lang}/>
+ return <NotFound />
}
const item = this.props.item
fields: { alias },
error,
handleSubmit,
- submitting
+ submitting,
+ t
} = this.props
const title = <span>
- {lang === 'zh' ? '编辑资产别名' : 'Edit asset alias '}
+ {t('asset.editAlias')}
<code>{item.alias ? item.alias :item.id}</code>
</span>
label={title}
onSubmit={handleSubmit(this.submitWithErrors)}
submitting={submitting}
- lang={lang}>
+ >
- <FormSection title={lang === 'zh' ? '资产别名' : 'Asset Alias' }>
+ <FormSection title={t('asset.alias') }>
<TextField
- placeholder={ lang === 'zh' ? '请输入资产别名' : 'Please entered asset alias' }
+ placeholder={ t('asset.aliasPlaceholder')}
fieldProps={alias}
type= 'text'
/>
const mapStateToProps = (state, ownProps) => ({
item: state.asset.items[ownProps.params.id],
- lang: state.core.lang
})
const initialValues = (state, ownProps) => {
fields: ['alias'],
}, initialValues)(Form)
-export default BaseUpdate.connect(
+export default withNamespaces('translations') (BaseUpdate.connect(
mapStateToProps,
BaseUpdate.mapDispatchToProps('asset'),
updateForm
-)
+))
import React from 'react'
import { BaseList, TableList } from 'features/shared/components'
import ListItem from './ListItem'
+import { withNamespaces } from 'react-i18next'
const type = 'asset'
-const mapStateToProps = (state) => {
- let titles
- if(state.core.lang === 'zh'){
- titles = ['资产别名','资产ID']
- }else{
- titles = ['Asset Alias', 'Asset ID']
- }
-
+const mapStateToProps = (state, props) => {
return {
...BaseList.mapStateToProps(type, ListItem, {
wrapperComponent: TableList,
wrapperProps: {
- titles: titles
+ titles: props.t('asset.formTitle', { returnObjects: true })
}
})(state)
}
}
-export default BaseList.connect(
+export default withNamespaces('translations') (BaseList.connect(
mapStateToProps,
BaseList.mapDispatchToProps(type)
-)
+))
import React from 'react'
import { Link } from 'react-router'
+import {withNamespaces} from 'react-i18next'
class ListItem extends React.Component {
render() {
- const item = this.props.item
- const lang = this.props.lang
+ const {item, t} = this.props
return(
<tr>
<td><code>{item.id}</code></td>
<td>
<Link to={`/assets/${item.id}`}>
- {lang === 'zh' ? '查看详情' : 'View details'} →
+ {t('commonWords.viewDetails')} →
</Link>
</td>
</tr>
}
}
-export default ListItem
+export default withNamespaces('translations') ( ListItem)
import React from 'react'
import { BaseNew, FormContainer, FormSection, JsonField, KeyConfiguration, TextField } from 'features/shared/components'
import { reduxForm } from 'redux-form'
+import {withNamespaces} from 'react-i18next'
class Form extends React.Component {
constructor(props) {
render() {
const {
- fields: { alias, tags, definition, xpubs, quorum },
+ fields: { alias, definition, xpubs, quorum },
error,
handleSubmit,
- submitting
+ submitting,
+ t
} = this.props
- const lang = this.props.lang
return(
<FormContainer
error={error}
- label= { lang === 'zh' ? '新建资产' : 'New asset' }
+ label= { t('asset.new') }
onSubmit={handleSubmit(this.submitWithErrors)}
submitting={submitting}
- lang={lang}>
+ >
- <FormSection title={ lang === 'zh' ? '资产信息' : 'Asset Information'}>
- <TextField title={ lang === 'zh' ? '别名' : 'Alias'} placeholder={ lang === 'zh' ? '别名' : 'Alias'} fieldProps={alias} autoFocus={true} />
- <JsonField title={ lang === 'zh' ? '定义' : 'Definition' } fieldProps={definition} lang={lang}/>
+ <FormSection title={t('asset.information')}>
+ <TextField title={t('form.alias')} placeholder={t('form.alias')} fieldProps={alias} autoFocus={true} />
+ <JsonField title={ t('form.definition') } fieldProps={definition}/>
</FormSection>
- <FormSection title={ lang === 'zh' ? '密钥和签名' :'Keys and Signing' }>
+ <FormSection title={t('asset.keyAndSign')}>
<KeyConfiguration
- lang={lang}
xpubs={xpubs}
quorum={quorum}
- quorumHint={ lang === 'zh' ? '所需的签名数' : 'Number of signatures required to issue' } />
+ quorumHint={t('asset.quorumHint')} />
</FormSection>
</FormContainer>
}
}
-const validate = (values,props) => {
+const validate = (values, props) => {
const errors = { xpubs:{} }
- const lang = props.lang
+ const t = props.t
const jsonFields = ['definition']
jsonFields.forEach(key => {
if (fieldError) { errors[key] = fieldError }
})
- if (!values.alias) { errors.alias = ( lang === 'zh' ? '资产别名是必须项' :'Asset alias is required' ) }
+ if (!values.alias) { errors.alias = t('asset.aliasError') }
values.xpubs.forEach((xpub, index) => {
if (!values.xpubs[index].value) {
- errors.xpubs[index] = {...errors.xpubs[index], value: ( lang === 'zh' ? '请输入或选择密钥' : 'Please provide keys' )}
+ errors.xpubs[index] = {...errors.xpubs[index], value: t('asset.keysError')}
}
})
'xpubs[].type',
'quorum'
]
-export default BaseNew.connect(
+export default withNamespaces('translations') ( BaseNew.connect(
BaseNew.mapStateToProps('asset'),
BaseNew.mapDispatchToProps('asset'),
reduxForm({
quorum: 1,
}
})(Form)
-)
+))
import React from 'react'
import { SelectField, XpubField } from 'features/shared/components'
+import {withNamespaces} from 'react-i18next'
const rangeOptions = [1,2,3,4,5,6].map(val => ({label: val, value: val}))
const {
quorum,
quorumHint,
- xpubs
+ xpubs,
+ t
} = this.props
// Override onChange here rather than in a redux-form normalizer because
}
const quorumOptions = rangeOptions.slice(0, this.state.keys)
- const lang = this.props.lang
return(
<div>
<SelectField options={rangeOptions}
- title={ lang === 'zh' ? '密钥数' : 'Keys' }
+ title={ t('form.keys') }
skipEmpty={true}
fieldProps={{
value: this.state.keys,
}} />
<SelectField options={quorumOptions}
- title={ lang === 'zh' ? '签名数' : 'Quorum' }
+ title={ t('form.quorum') }
skipEmpty={true}
hint={quorumHint}
fieldProps={{
index={index}
typeProps={xpub.type}
valueProps={xpub.value}
- lang={lang}
/>)}
</div>
)
}
}
-export default KeyConfiguration
+export default withNamespaces('translations') (KeyConfiguration)
import { SelectField, FieldLabel, TextField } from '../'
import { connect } from 'react-redux'
import actions from 'features/mockhsm/actions'
+import {withNamespaces} from 'react-i18next'
-const methodOptions = {
- mockhsm: 'Use existing key',
- // generate: 'Generate new MockHSM key',
- provide: 'Provide existing xpub',
-}
-
-const methodOptionsZh = {
- mockhsm: '使用已有的密钥',
- // generate: 'Generate new MockHSM key',
- provide: '提供已有的扩展公钥',
-}
+const methodOptions = ['mockhsm', 'provide']
class XpubField extends React.Component {
constructor(props) {
})
}
- this.props.typeProps.onChange(Object.keys(methodOptions)[0])
+ this.props.typeProps.onChange(methodOptions[0])
}
render() {
typeProps,
valueProps,
mockhsmKeys,
+ t
} = this.props
- const lang = this.props.lang
const typeOnChange = event => {
const value = typeProps.onChange(event).value
autoFocus={this.state.autofocusInput}
valueKey='xpub'
labelKey='label'
- lang={lang}
fieldProps={{...valueProps, onChange: valueOnChange}} />,
'provide': <TextField
autoFocus={this.state.autofocusInput}
fieldProps={{...valueProps, onChange: valueOnChange}}
- placeholder={ lang === 'zh' ? '输入扩展公钥' : 'Enter xpub' } />,
+ placeholder={ t('xpub.providePlaceholder') } />,
'generate': <TextField
autoFocus={this.state.autofocusInput}
fieldProps={{...valueProps, onChange: valueOnChange}}
return (
<div className={styles.main}>
- <FieldLabel>{ lang === 'zh' ? '密钥' :'Key '}{this.props.index + 1}</FieldLabel>
+ <FieldLabel>{t('form.key')}{this.props.index + 1}</FieldLabel>
<table className={styles.options}>
<tbody>
- {Object.keys(methodOptions).map((key) =>
+ {methodOptions.map((key) =>
<tr key={`key-${this.props.index}-option-${key}`}>
<td className={styles.label}>
<label>
checked={key == typeProps.value}
value={key}
/>
- { lang === 'zh' ? methodOptionsZh[key] : methodOptions[key]}
+ { t('xpub.methodOptions', { returnObjects: true })[key]}
</label>
</td>
return {
autocompleteIsLoaded: state.key.autocompleteIsLoaded,
mockhsmKeys: keys,
- lang: state.core.lang
}
},
(dispatch) => ({
didLoadAutocomplete: () => dispatch(actions.didLoadAutocomplete),
fetchAll: (cb) => dispatch(actions.fetchAll(cb)),
})
-)(XpubField)
+)(withNamespaces('translations')(XpubField))
ns: ['translations'],
defaultNS: 'translations',
- keySeparator: false, // we use content as keys
-
interpolation: {
escapeValue: false, // not needed for react!!
- formatSeparator: ','
+ prefix: '__',
+ suffix: '__'
},
react: {