Skip to content

Instantly share code, notes, and snippets.

View ryandrewjohnson's full-sized avatar

Ryan Johnson ryandrewjohnson

View GitHub Profile
@ryandrewjohnson
ryandrewjohnson / movie.json
Last active July 1, 2018 01:05
react-localize-redux - movies.json
{
"movie": {
"title": ["Jurassic Park", "Le Parc jurassique"]
}
}
@ryandrewjohnson
ryandrewjohnson / translate-renderprops.jsx
Last active July 1, 2018 01:03
react-localize-redux - renderprops.jsx
const Movies = props => (
<Translate>
{({ translate }) => <h1>{translate("movie.title")}</h1>}
</Translate>
);
@ryandrewjohnson
ryandrewjohnson / translate-placeholder.js
Last active April 7, 2018 02:41
react-localize-redux - app-01.js
import { Translate } from 'react-localize-redux';
const Profile = props => (
<Translate id="profile" data={{ name: 'Ted', date: new Date() }}>
{'User: ${name} last login ${date}'}
</Translate>
);
@ryandrewjohnson
ryandrewjohnson / translate-selfclosing.jsx
Last active July 1, 2018 01:02
react-localize-redux - Translate with self-closing tag
const Movies = props => (
<h1>
<Translate id="movie.title" />
</h1>
);
@ryandrewjohnson
ryandrewjohnson / translate-with-defaults.jsx
Last active July 1, 2018 01:00
react-localize-redux - Translate with default translations:
import React from "react";
import { Translate } from "react-localize-redux";
const Movies = props => (
<h1>
<Translate id="movie.title">Jurassic Park</Translate>
</h1>
);
@ryandrewjohnson
ryandrewjohnson / addTranslation.jsx
Last active July 1, 2018 00:54
react-localize-redux - addTranslations.js
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);
}
@ryandrewjohnson
ryandrewjohnson / movie.json
Created July 12, 2017 00:14
react-localize-redux - movie.json
{
"movie": {
"title": ["Jurassic Park"],
"desc": ["Lots of dinos!"],
"stars": ["${ stars } out of 5"]
}
}
@ryandrewjohnson
ryandrewjohnson / global.json
Last active July 12, 2017 00:10
react-localize-redux - global.js
{
"title": ["Movie Reviews"],
"search": ["<a href='http://www.imdb.com/'>Search IMDb</a>"],
"copyright": ["copyright ${ year }"]
}
@ryandrewjohnson
ryandrewjohnson / addTranslationForLanguage.jsx
Last active July 1, 2018 00:57
react-localize-redux - addTranslationForLanguage.jsx
import frenchMovieTranslations from "./translations/fr.movies.json";
this.props.addTranslationForLanguage(frenchMovieTranslations, "fr");
@ryandrewjohnson
ryandrewjohnson / initialize.jsx
Last active July 1, 2018 00:50
react-localize-redux - setLanguages.js
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({