Created
November 4, 2022 07:25
-
-
Save enricop89/f4975dc98302cc5b8cfdb0b9ad79c7a0 to your computer and use it in GitHub Desktop.
Localize App.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { I18n } from "aws-amplify"; | |
import { Link } from "react-router-dom"; | |
function About() { | |
return ( | |
<section id="aboutSection"> | |
<p>{I18n.get("aboutTitle")}</p> | |
<p> | |
Go to <Link to="/">Home</Link> | |
</p> | |
</section> | |
); | |
} | |
export default About; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "./App.css"; | |
import languages from "./languages"; | |
import { | |
createBrowserRouter, | |
RouterProvider, | |
BrowserRouter as Router, | |
Routes, | |
Route, | |
} from "react-router-dom"; | |
import Home from "./components/Home"; | |
import About from "./components/About"; | |
import { I18n } from "aws-amplify"; | |
I18n.putVocabularies(languages); | |
I18n.setLanguage("en"); | |
function App() { | |
return ( | |
<Router> | |
<Routes> | |
<Route path="/" element={<Home />} /> | |
<Route path="/about" element={<About />} /> | |
</Routes> | |
</Router> | |
); | |
} | |
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { I18n } from "aws-amplify"; | |
import { Link } from "react-router-dom"; | |
function Home() { | |
return ( | |
<section id="mainSection"> | |
<p>{I18n.get("mainTitle")}</p> | |
<p>{I18n.get("secondaryTitle")}</p> | |
<p> | |
Go to <Link to="about">About Us</Link> | |
</p> | |
</section> | |
); | |
} | |
export default Home; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment