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 React from "react"; | |
import { withLocalize } from "react-localize-redux"; | |
const LanguageToggle = ({ languages, activeLanguage, setActiveLanguage }) => ( | |
<ul className="selector"> | |
{languages.map(lang => ( | |
<li key={lang.code}> | |
<button onClick={() => setActiveLanguage(lang.code)}> | |
{lang.name} | |
</button> |
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
{ | |
"movie": { | |
"title": ["Jurassic Park", "Le Parc jurassique"] | |
} | |
} |
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
const Movies = props => ( | |
<Translate> | |
{({ translate }) => <h1>{translate("movie.title")}</h1>} | |
</Translate> | |
); |
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
const Movies = props => ( | |
<h1> | |
<Translate id="movie.title" /> | |
</h1> | |
); |
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 React from "react"; | |
import { Translate } from "react-localize-redux"; | |
const Movies = props => ( | |
<h1> | |
<Translate id="movie.title">Jurassic Park</Translate> | |
</h1> | |
); |
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 frenchMovieTranslations from "./translations/fr.movies.json"; | |
this.props.addTranslationForLanguage(frenchMovieTranslations, "fr"); |
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 React from "react"; | |
import { withLocalize } from "react-localize-redux"; | |
import movieTranslations from "./translations/movies.json"; | |
class Movies extends React.Component { | |
constructor(props) { | |
super(props); | |
this.props.addTranslation(movieTranslations); | |
} |
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 React from "react"; | |
import { renderToStaticMarkup } from "react-dom/server"; | |
import { withLocalize } from "react-localize-redux"; | |
import globalTranslations from "./translations/global.json"; | |
class Main extends React.Component { | |
constructor(props) { | |
super(props); | |
this.props.initialize({ |
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 React from "react"; | |
import { render } from "react-dom"; | |
import { BrowserRouter as Router, Route } from "react-router-dom"; | |
import { LocalizeProvider } from "react-localize-redux"; | |
import Main from "./Main"; | |
const App = props => ( | |
<LocalizeProvider> | |
<Router> | |
<Route path="/" component={Main} /> |
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 React from 'react'; | |
import Enzyme, { mount } from 'enzyme'; | |
// ensure you're resetting modules before each test | |
beforeEach(() => { | |
jest.resetModules(); | |
}); | |
// Takes the context data we want to test, or uses defaults | |
const getLanguageSelectorWithContext = (context = {languages: ['en', 'fr', 'es'], activeLanguage: 'en'}) => { |
NewerOlder