File tree Expand file tree Collapse file tree 11 files changed +157
-11
lines changed Expand file tree Collapse file tree 11 files changed +157
-11
lines changed Original file line number Diff line number Diff line change 1313 "react" : " ^16.12.0" ,
1414 "react-app-rewired" : " ^2.1.5" ,
1515 "react-dom" : " ^16.12.0" ,
16+ "react-intl" : " ^3.11.0" ,
1617 "react-scripts" : " 3.3.0"
1718 },
1819 "scripts" : {
Original file line number Diff line number Diff line change 2424 work correctly both with client-side routing and a non-root public URL.
2525 Learn how to configure a non-root public URL by running `npm run build`.
2626 -->
27- < title > React App</ title >
27+ < title > React App Template </ title >
2828 </ head >
2929 < body >
3030 < noscript > You need to enable JavaScript to run this app.</ noscript >
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { useRoutes } from 'hookrouter' ;
3+ import { IntlProvider } from 'react-intl' ;
4+ import messages_en from './translations/en.json' ;
5+ import messages_vi from './translations/vi.json' ;
36import routes from './router' ;
47import NoPageFound from './pages/NoPageFound/NoPageFound' ;
58import './App.scss' ;
69
10+ const messages = {
11+ en : messages_en ,
12+ vi : messages_vi
13+ } ;
14+
15+ const language = 'en' ;
16+
717const App = ( ) => {
818 console . log ( 'This console will be remove in Production mode' ) ;
919 const routeResult = useRoutes ( routes ) ;
1020
1121 return (
12- < div className = "app-container" >
13- { routeResult || < NoPageFound /> }
14- </ div >
22+ < IntlProvider locale = { language } messages = { messages [ language ] } >
23+ < div className = "app-container" > { routeResult || < NoPageFound /> } </ div >
24+ </ IntlProvider >
1525 ) ;
16- }
26+ } ;
1727
1828export default App ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import { FormattedMessage } from 'react-intl' ;
23import Navigation from '../../components/Navigation/Navigation' ;
34import Title from '../../components/Title/Title' ;
45import './Blog.scss' ;
@@ -7,7 +8,9 @@ const Blog = ({ blogId }) => {
78 return (
89 < div className = "blog-container" >
910 < Navigation />
10- < Title > { `Blog Page with id: ${ blogId } ` } </ Title >
11+ < Title >
12+ < FormattedMessage id = "IDS_BLOG_PAGE_WITH_ID" values = { { blogId } } />
13+ </ Title >
1114 </ div >
1215 ) ;
1316} ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import { FormattedMessage } from 'react-intl' ;
23import Navigation from '../../components/Navigation/Navigation' ;
34import Title from '../../components/Title/Title' ;
45import './HomePage.scss' ;
@@ -7,7 +8,9 @@ const HomePage = () => {
78 return (
89 < div className = "home-page-container" >
910 < Navigation />
10- < Title > Home Page</ Title >
11+ < Title >
12+ < FormattedMessage id = "IDS_HOME_PAGE" />
13+ </ Title >
1114 </ div >
1215 ) ;
1316} ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import { FormattedMessage } from 'react-intl' ;
23import Navigation from '../../components/Navigation/Navigation' ;
34import Title from '../../components/Title/Title' ;
45import './NoPageFound.scss' ;
@@ -7,7 +8,9 @@ const NoPageFound = () => {
78 return (
89 < div className = "no-page-found-container" >
910 < Navigation />
10- < Title > No Page Found</ Title >
11+ < Title >
12+ < FormattedMessage id = "IDS_NO_PAGE_FOUND" />
13+ </ Title >
1114 </ div >
1215 ) ;
1316} ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import { FormattedMessage } from 'react-intl' ;
23import Navigation from '../../components/Navigation/Navigation' ;
34import Title from '../../components/Title/Title' ;
45import './PrivacyPolicy.scss' ;
@@ -7,7 +8,9 @@ const PrivacyPolicy = () => {
78 return (
89 < div className = "privacy-policy-container" >
910 < Navigation />
10- < Title > Privacy Policy</ Title >
11+ < Title >
12+ < FormattedMessage id = "IDS_PRIVACY_POLICY" />
13+ </ Title >
1114 </ div >
1215 ) ;
1316} ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import { FormattedMessage } from 'react-intl' ;
23import Navigation from '../../components/Navigation/Navigation' ;
34import Title from '../../components/Title/Title' ;
45import './TermsOfUse.scss' ;
@@ -7,7 +8,9 @@ const TermsOfUse = () => {
78 return (
89 < div className = "terms-of-use-container" >
910 < Navigation />
10- < Title > Terms of Use</ Title >
11+ < Title >
12+ < FormattedMessage id = "IDS_TERMS_OF_USE" />
13+ </ Title >
1114 </ div >
1215 ) ;
1316} ;
Original file line number Diff line number Diff line change 1+ {
2+ "IDS_HOME_PAGE" : " Home Page" ,
3+ "IDS_NO_PAGE_FOUND" : " No Page Found" ,
4+ "IDS_PRIVACY_POLICY" : " Privacy Policy" ,
5+ "IDS_TERMS_OF_USE" : " Terms of Use" ,
6+ "IDS_BLOG_PAGE_WITH_ID" : " Blog Page with id: {blogId}"
7+ }
Original file line number Diff line number Diff line change 1+ {
2+ "IDS_HOME_PAGE" : " Trang chủ" ,
3+ "IDS_NO_PAGE_FOUND" : " Trang không tìm thấy" ,
4+ "IDS_PRIVACY_POLICY" : " Chính sách bảo mật" ,
5+ "IDS_TERMS_OF_USE" : " Điều khoản sử dụng" ,
6+ "IDS_BLOG_PAGE_WITH_ID" : " Trang blog với id: {blogId}"
7+ }
You can’t perform that action at this time.
0 commit comments