Browse Source

Add translations

master
meriadec 7 years ago
parent
commit
fc5d701340
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 2
      src/components/DashboardPage/AccountsOrder.js
  2. 32
      src/components/DashboardPage/index.js
  3. 11
      src/components/GlobalSearch.js
  4. 5
      src/components/SettingsPage/Display.js
  5. 10
      src/components/SettingsPage/Profile.js
  6. 1
      src/components/SettingsPage/index.js
  7. 14
      src/components/TopBar.js
  8. 29
      src/components/TransactionsList/index.js
  9. 27
      static/i18n/en/translation.yml
  10. 29
      static/i18n/fr/translation.yml

2
src/components/DashboardPage/AccountsOrder.js

@ -183,7 +183,7 @@ class AccountsOrder extends Component<Props, State> {
value={sortItems.find(item => item.key === cachedValue)} value={sortItems.find(item => item.key === cachedValue)}
> >
<Text ff="Open Sans|SemiBold" fontSize={4}> <Text ff="Open Sans|SemiBold" fontSize={4}>
{'Sort by'} {t('global.sortBy')}
</Text> </Text>
<Box <Box
alignItems="center" alignItems="center"

32
src/components/DashboardPage/index.js

@ -13,7 +13,7 @@ import sortBy from 'lodash/sortBy'
import takeRight from 'lodash/takeRight' import takeRight from 'lodash/takeRight'
import type { MapStateToProps } from 'react-redux' import type { MapStateToProps } from 'react-redux'
import type { Accounts } from 'types/common' import type { Accounts, T } from 'types/common'
import { space } from 'styles/theme' import { space } from 'styles/theme'
@ -43,6 +43,7 @@ const mapDispatchToProps = {
} }
type Props = { type Props = {
t: T,
accounts: Accounts, accounts: Accounts,
push: Function, push: Function,
} }
@ -59,12 +60,7 @@ const ACCOUNTS_BY_LINE = 3
const ALL_TRANSACTIONS_LIMIT = 10 const ALL_TRANSACTIONS_LIMIT = 10
const TIMEOUT_REFRESH_DATAS = 5e3 const TIMEOUT_REFRESH_DATAS = 5e3
const itemsTimes = [ const itemsTimes = [{ key: 'day' }, { key: 'week' }, { key: 'month' }, { key: 'year' }]
{ key: 'day', label: 'Day' },
{ key: 'week', label: 'Week' },
{ key: 'month', label: 'Month' },
{ key: 'year', label: 'Year' },
]
const generateFakeData = v => ({ const generateFakeData = v => ({
name: `Day ${v}`, name: `Day ${v}`,
@ -132,6 +128,13 @@ class DashboardPage extends PureComponent<Props, State> {
} }
} }
componentWillMount() {
this._itemsTimes = itemsTimes.map(item => ({
...item,
label: this.props.t(`time.${item.key}`),
}))
}
componentDidMount() { componentDidMount() {
this._mounted = true this._mounted = true
@ -190,9 +193,10 @@ class DashboardPage extends PureComponent<Props, State> {
_timeout = undefined _timeout = undefined
_mounted = false _mounted = false
_itemsTimes = []
render() { render() {
const { push, accounts } = this.props const { push, accounts, t } = this.props
const { accountsChunk, allTransactions, selectedTime, fakeDatas, fakeDatasMerge } = this.state const { accountsChunk, allTransactions, selectedTime, fakeDatas, fakeDatasMerge } = this.state
let accountIndex = 0 let accountIndex = 0
@ -203,17 +207,17 @@ class DashboardPage extends PureComponent<Props, State> {
<Box horizontal alignItems="flex-end"> <Box horizontal alignItems="flex-end">
<Box> <Box>
<Text color="dark" ff="Museo Sans" fontSize={7}> <Text color="dark" ff="Museo Sans" fontSize={7}>
{'Good morning, Khalil.'} {t('dashboard.greetings', { name: 'Khalil' })}
</Text> </Text>
<Text color="grey" fontSize={5} ff="Museo Sans|Light"> <Text color="grey" fontSize={5} ff="Museo Sans|Light">
{totalAccounts > 0 {totalAccounts > 0
? `here is the summary of your ${totalAccounts} accounts` ? t('dashboard.summary', { count: totalAccounts })
: 'no accounts'} : t('dashboard.noAccounts')}
</Text> </Text>
</Box> </Box>
<Box ml="auto"> <Box ml="auto">
<Pills <Pills
items={itemsTimes} items={this._itemsTimes}
activeKey={selectedTime} activeKey={selectedTime}
onChange={item => this.setState({ selectedTime: item.key })} onChange={item => this.setState({ selectedTime: item.key })}
/> />
@ -243,7 +247,7 @@ class DashboardPage extends PureComponent<Props, State> {
<Box flow={4}> <Box flow={4}>
<Box horizontal alignItems="flex-end"> <Box horizontal alignItems="flex-end">
<Text color="dark" ff="Museo Sans" fontSize={6}> <Text color="dark" ff="Museo Sans" fontSize={6}>
{'Accounts'} {t('sidebar.accounts')}
</Text> </Text>
<Box ml="auto" horizontal flow={1}> <Box ml="auto" horizontal flow={1}>
<AccountsOrder /> <AccountsOrder />
@ -277,7 +281,7 @@ class DashboardPage extends PureComponent<Props, State> {
))} ))}
</Box> </Box>
</Box> </Box>
<Card p={0} px={4} title="Recent activity"> <Card p={0} px={4} title={t('dashboard.recentActivity')}>
<TransactionsList <TransactionsList
withAccounts withAccounts
transactions={allTransactions} transactions={allTransactions}

11
src/components/GlobalSearch.js

@ -3,6 +3,8 @@
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import type { T } from 'types/common'
import IconSearch from 'icons/Search' import IconSearch from 'icons/Search'
import Box from 'components/base/Box' import Box from 'components/base/Box'
@ -30,7 +32,11 @@ type State = {
isFocused: boolean, isFocused: boolean,
} }
class GlobalSearch extends PureComponent<{}, State> { type Props = {
t: T,
}
class GlobalSearch extends PureComponent<Props, State> {
state = { state = {
isFocused: false, isFocused: false,
} }
@ -54,6 +60,7 @@ class GlobalSearch extends PureComponent<{}, State> {
}) })
render() { render() {
const { t } = this.props
const { isFocused } = this.state const { isFocused } = this.state
return ( return (
@ -62,7 +69,7 @@ class GlobalSearch extends PureComponent<{}, State> {
<IconSearch height={16} width={16} /> <IconSearch height={16} width={16} />
</Box> </Box>
<Input <Input
placeholder="Search" placeholder={t('global.search')}
innerRef={input => (this._input = input)} innerRef={input => (this._input = input)}
onBlur={this.handleBlur} onBlur={this.handleBlur}
onFocus={this.handleFocus} onFocus={this.handleFocus}

5
src/components/SettingsPage/Display.js

@ -1,7 +1,6 @@
// @flow // @flow
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import { translate } from 'react-i18next'
import type { SettingsDisplay, T } from 'types/common' import type { SettingsDisplay, T } from 'types/common'
@ -88,7 +87,7 @@ class TabProfile extends PureComponent<Props, State> {
</Box> </Box>
<Box horizontal justifyContent="flex-end"> <Box horizontal justifyContent="flex-end">
<Button primary type="submit"> <Button primary type="submit">
Save {t('global.save')}
</Button> </Button>
</Box> </Box>
</Card> </Card>
@ -97,4 +96,4 @@ class TabProfile extends PureComponent<Props, State> {
} }
} }
export default translate()(TabProfile) export default TabProfile

10
src/components/SettingsPage/Profile.js

@ -9,7 +9,7 @@ import set from 'lodash/set'
import { setEncryptionKey } from 'helpers/db' import { setEncryptionKey } from 'helpers/db'
import type { SettingsProfile } from 'types/common' import type { SettingsProfile, T } from 'types/common'
import { unlock } from 'reducers/application' import { unlock } from 'reducers/application'
@ -22,6 +22,7 @@ import Label from 'components/base/Label'
type InputValue = SettingsProfile type InputValue = SettingsProfile
type Props = { type Props = {
t: T,
settings: SettingsProfile, settings: SettingsProfile,
onSaveSettings: Function, onSaveSettings: Function,
unlock: Function, unlock: Function,
@ -80,6 +81,7 @@ class TabProfile extends PureComponent<Props, State> {
} }
render() { render() {
const { t } = this.props
const { inputValue } = this.state const { inputValue } = this.state
const isPasswordChecked = get(inputValue, 'password.state', false) const isPasswordChecked = get(inputValue, 'password.state', false)
@ -95,12 +97,12 @@ class TabProfile extends PureComponent<Props, State> {
onClick={() => this.handleChangeInput('password.state')(!isPasswordChecked)} onClick={() => this.handleChangeInput('password.state')(!isPasswordChecked)}
> >
<CheckBox isChecked={isPasswordChecked} /> <CheckBox isChecked={isPasswordChecked} />
<div>{' Protect local data with a password'}</div> <div>{t('settings.profile.protectWithPassword')}</div>
</Box> </Box>
</label> </label>
{get(inputValue, 'password.state') === true && ( {get(inputValue, 'password.state') === true && (
<Box flow={1}> <Box flow={1}>
<Label>Password</Label> <Label>{t('settings.profile.password')}</Label>
<Input <Input
value={get(inputValue, 'password.value', '')} value={get(inputValue, 'password.value', '')}
onChange={this.handleChangeInput('password.value')} onChange={this.handleChangeInput('password.value')}
@ -110,7 +112,7 @@ class TabProfile extends PureComponent<Props, State> {
)} )}
<Box horizontal justifyContent="flex-end"> <Box horizontal justifyContent="flex-end">
<Button primary type="submit"> <Button primary type="submit">
Save {t('global.save')}
</Button> </Button>
</Box> </Box>
</Card> </Card>

1
src/components/SettingsPage/index.js

@ -59,6 +59,7 @@ class SettingsPage extends PureComponent<Props, State> {
const { tab } = this.state const { tab } = this.state
const props = { const props = {
t,
settings, settings,
onSaveSettings: this.handleSaveSettings, onSaveSettings: this.handleSaveSettings,
} }

14
src/components/TopBar.js

@ -1,11 +1,14 @@
// @flow // @flow
import React, { PureComponent } from 'react' import React, { PureComponent } from 'react'
import { compose } from 'redux'
import { translate } from 'react-i18next'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import styled from 'styled-components' import styled from 'styled-components'
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import type { MapStateToProps, MapDispatchToProps } from 'react-redux' import type { MapStateToProps, MapDispatchToProps } from 'react-redux'
import type { T } from 'types/common'
import { rgba } from 'styles/helpers' import { rgba } from 'styles/helpers'
import { getAccounts } from 'reducers/accounts' import { getAccounts } from 'reducers/accounts'
@ -80,6 +83,7 @@ const mapDispatchToProps: MapDispatchToProps<*, *, *> = {
} }
type Props = { type Props = {
t: T,
hasAccounts: boolean, hasAccounts: boolean,
hasPassword: boolean, hasPassword: boolean,
lock: Function, lock: Function,
@ -140,14 +144,14 @@ class TopBar extends PureComponent<Props, State> {
handleLock = () => this.props.lock() handleLock = () => this.props.lock()
render() { render() {
const { hasPassword, hasAccounts } = this.props const { hasPassword, hasAccounts, t } = this.props
const { sync } = this.state const { sync } = this.state
return ( return (
<Container bg="cream" color="warmGrey"> <Container bg="cream" color="warmGrey">
<Inner> <Inner>
<Box grow horizontal flow={4}> <Box grow horizontal flow={4}>
<GlobalSearch /> <GlobalSearch t={t} />
<Box justifyContent="center"> <Box justifyContent="center">
<IconDevices height={16} width={16} /> <IconDevices height={16} width={16} />
</Box> </Box>
@ -164,14 +168,14 @@ class TopBar extends PureComponent<Props, State> {
items={[ items={[
{ {
key: 'profile', key: 'profile',
label: 'Edit profile', label: t('mainDropdown.editProfile'),
icon: <IconUser height={16} width={16} />, icon: <IconUser height={16} width={16} />,
}, },
...(hasPassword ...(hasPassword
? [ ? [
{ {
key: 'lock', key: 'lock',
label: 'Lock application', label: t('mainDropdown.lockApplication'),
icon: <IconUser height={16} width={16} />, icon: <IconUser height={16} width={16} />,
onClick: this.handleLock, onClick: this.handleLock,
}, },
@ -203,4 +207,4 @@ class TopBar extends PureComponent<Props, State> {
} }
} }
export default connect(mapStateToProps, mapDispatchToProps)(TopBar) export default compose(connect(mapStateToProps, mapDispatchToProps), translate())(TopBar)

29
src/components/TransactionsList/index.js

@ -3,12 +3,13 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import moment from 'moment' import moment from 'moment'
import { translate } from 'react-i18next'
import get from 'lodash/get' import get from 'lodash/get'
import noop from 'lodash/noop' import noop from 'lodash/noop'
import isEqual from 'lodash/isEqual' import isEqual from 'lodash/isEqual'
import { getIconByCoinType } from '@ledgerhq/currencies/react' import { getIconByCoinType } from '@ledgerhq/currencies/react'
import type { Transaction as TransactionType } from 'types/common' import type { Transaction as TransactionType, T } from 'types/common'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import Defer from 'components/base/Defer' import Defer from 'components/base/Defer'
@ -71,10 +72,12 @@ const Cell = styled(Box).attrs({
` `
const Transaction = ({ const Transaction = ({
t,
onAccountClick, onAccountClick,
tx, tx,
withAccounts, withAccounts,
}: { }: {
t: T,
onAccountClick?: Function, onAccountClick?: Function,
tx: TransactionType, tx: TransactionType,
withAccounts?: boolean, withAccounts?: boolean,
@ -117,7 +120,7 @@ const Transaction = ({
}} }}
> >
<Box ff="Open Sans" fontSize={3} color="lead"> <Box ff="Open Sans" fontSize={3} color="lead">
{tx.balance > 0 ? 'From' : 'To'} {tx.balance > 0 ? t('transactionsList.from') : t('transactionsList.to')}
</Box> </Box>
<Box color="dark" ff="Open Sans" fontSize={3}> <Box color="dark" ff="Open Sans" fontSize={3}>
{tx.address} {tx.address}
@ -142,6 +145,7 @@ Transaction.defaultProps = {
} }
type Props = { type Props = {
t: T,
onAccountClick?: Function, onAccountClick?: Function,
transactions: Array<TransactionType>, transactions: Array<TransactionType>,
withAccounts?: boolean, withAccounts?: boolean,
@ -166,28 +170,31 @@ class TransactionsList extends Component<Props> {
_hashCache = null _hashCache = null
render() { render() {
const { transactions, withAccounts, onAccountClick } = this.props const { transactions, withAccounts, onAccountClick, t } = this.props
this._hashCache = this.getHashCache(transactions) this._hashCache = this.getHashCache(transactions)
return ( return (
<Box flow={1}> <Box flow={1}>
<Box horizontal pt={4}> <Box horizontal pt={4}>
<HeaderCol size={DATE_COL_SIZE}>{'Date'}</HeaderCol> <HeaderCol size={DATE_COL_SIZE}>{t('transactionsList.date')}</HeaderCol>
{withAccounts && <HeaderCol size={ACCOUNT_COL_SIZE}>{'Account'}</HeaderCol>} {withAccounts && (
<HeaderCol grow>{'Address'}</HeaderCol> <HeaderCol size={ACCOUNT_COL_SIZE}>{t('transactionsList.account')}</HeaderCol>
)}
<HeaderCol grow>{t('transactionsList.address')}</HeaderCol>
<HeaderCol size={AMOUNT_COL_SIZE} justifyContent="flex-end"> <HeaderCol size={AMOUNT_COL_SIZE} justifyContent="flex-end">
{'Amount'} {t('transactionsList.amount')}
</HeaderCol> </HeaderCol>
</Box> </Box>
<Defer> <Defer>
<Box> <Box>
{transactions.map(t => ( {transactions.map(trans => (
<Transaction <Transaction
key={`{${t.hash}-${t.account ? t.account.id : ''}`} t={t}
key={`{${trans.hash}-${trans.account ? trans.account.id : ''}`}
withAccounts={withAccounts} withAccounts={withAccounts}
onAccountClick={onAccountClick} onAccountClick={onAccountClick}
tx={t} tx={trans}
/> />
))} ))}
</Box> </Box>
@ -197,4 +204,4 @@ class TransactionsList extends Component<Props> {
} }
} }
export default TransactionsList export default translate()(TransactionsList)

27
static/i18n/en/translation.yml

@ -18,6 +18,11 @@ device:
notConnected: Not connected notConnected: Not connected
dashboard: dashboard:
title: Dashboard title: Dashboard
greetings: 'Good morning, {{name}}.'
summary: here is the summary of your account
summary_plural: 'here is the summary of your {{count}} accounts'
noAccounts: no accounts
recentActivity: Recent activity
send: send:
title: Send title: Send
receive: receive:
@ -39,6 +44,9 @@ settings:
display: display:
language: Language language: Language
orderAccounts: Order accounts orderAccounts: Order accounts
profile:
protectWithPassword: Protect local data with a password
password: Password
SelectAccount: SelectAccount:
placeholder: Select an account placeholder: Select an account
AccountPage: AccountPage:
@ -55,3 +63,22 @@ sendModal:
Summary: Summary Summary: Summary
SecureValidation: Secure validation SecureValidation: Secure validation
Confirmation: Confirmation Confirmation: Confirmation
time:
day: Day
week: Week
month: Month
year: Year
global:
sortBy: Sort by
search: Search
save: Save
transactionsList:
date: Date
account: Account
address: Address
amount: Amount
from: From
to: To
mainDropdown:
editProfile: Edit profile
lockApplication: Lock application

29
static/i18n/fr/translation.yml

@ -18,6 +18,11 @@ device:
notConnected: Non connecté notConnected: Non connecté
dashboard: dashboard:
title: Tableau de bord title: Tableau de bord
greetings: 'Bonjour, {{name}}.'
summary: voici le résumé de votre compte
summary_plural: 'voici le résumé de vos {{count}} comptes'
noAccounts: aucun compte
recentActivity: Activité récente
send: send:
title: Envoyer title: Envoyer
receive: receive:
@ -37,8 +42,11 @@ settings:
blockchain: Blockchain blockchain: Blockchain
profile: Profil profile: Profil
display: display:
language: Langage language: Langue
orderAccounts: Ordre des comptes orderAccounts: Ordre des comptes
profile:
protectWithPassword: Protégez les données locales avec un mot de passe
password: Mot de passe
SelectAccount: SelectAccount:
placeholder: Sélectionner un compte placeholder: Sélectionner un compte
AccountPage: AccountPage:
@ -55,3 +63,22 @@ sendModal:
Summary: Résumé Summary: Résumé
SecureValidation: Validation sécurisée SecureValidation: Validation sécurisée
Confirmation: Confirmation Confirmation: Confirmation
time:
day: Jour
week: Semaine
month: Mois
year: Année
global:
sortBy: Trier par
search: Rechercher
save: Sauvegarder
transactionsList:
date: Date
account: Compte
address: Adresse
amount: Montant
from: Depuis
to: Vers
mainDropdown:
editProfile: Éditer le profil
lockApplication: Verrouiller l'application

Loading…
Cancel
Save