1
1
import React , { Component } from 'react' ;
2
- import i18n from 'I18nSetup' ;
3
2
import { withTranslation } from 'react-i18next' ;
4
3
import PropTypes from 'prop-types' ;
4
+ import 'I18nSetup' ;
5
5
6
6
/**
7
7
* CandidateInfo is a React component which is used for the
@@ -37,9 +37,15 @@ class CandidateInfo extends Component {
37
37
const months = years * 12 + now . getMonth ( ) - dobdate . getMonth ( ) ;
38
38
39
39
if ( months <= 36 ) {
40
- return this . props . t ( '{{months}} months old' , { ns : 'loris' , months : months } ) ;
40
+ return this . props . t (
41
+ '{{months}} months old' ,
42
+ { ns : 'loris' , months : months }
43
+ ) ;
41
44
}
42
- return this . props . t ( '{{years}} years old' , { ns : 'loris' , years : years } ) ;
45
+ return this . props . t (
46
+ '{{years}} years old' ,
47
+ { ns : 'loris' , years : years }
48
+ ) ;
43
49
}
44
50
45
51
/**
@@ -107,6 +113,14 @@ class CandidateInfo extends Component {
107
113
*/
108
114
render ( ) {
109
115
const cohorts = this . getCohorts ( this . props . Visits ) ;
116
+ const dateFormatter = new Intl . DateTimeFormat (
117
+ loris . user . langpref . replace ( '_' , '-' ) ,
118
+ {
119
+ style : 'short' ,
120
+ timeZone : 'UTC' ,
121
+
122
+ }
123
+ ) ;
110
124
111
125
const data = [
112
126
{
@@ -119,7 +133,7 @@ class CandidateInfo extends Component {
119
133
} ,
120
134
{
121
135
label : this . props . t ( 'Date of Birth' , { ns : 'loris' } ) ,
122
- value : this . props . Candidate . Meta . DoB ,
136
+ value : dateFormatter . format ( new Date ( this . props . Candidate . Meta . DoB ) ) ,
123
137
valueWhitespace : 'nowrap' ,
124
138
} ,
125
139
{
@@ -210,6 +224,11 @@ CandidateInfo.propTypes = {
210
224
Visits : PropTypes . array . isRequired ,
211
225
VisitMap : PropTypes . object . isRequired ,
212
226
ExtraCandidateInfo : PropTypes . array ,
227
+
228
+ // Provided by withTranslation HOC
229
+ t : PropTypes . func ,
213
230
} ;
214
231
215
- export default { CandidateInfo : withTranslation ( [ 'candidate_profile' , 'loris' ] ) ( CandidateInfo ) } ;
232
+ export default {
233
+ CandidateInfo : withTranslation ( [ 'candidate_profile' , 'loris' ] ) ( CandidateInfo ) ,
234
+ } ;
0 commit comments