Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRACKING: feature/redux → feature/react-intl #1135

Closed
wants to merge 206 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
86eadfd
React Intl
langpavel Apr 22, 2016
1ab3873
Merge pull request #609 from langpavel/feature/react-intl
koistya Apr 22, 2016
4819cf4
Upgrade accidentaly downgraded history dependency
langpavel Apr 22, 2016
4a49f36
Merge pull request #616 from langpavel/feature/react-intl
koistya Apr 23, 2016
fd79c1d
Merge branch 'master' into feature/react-intl
langpavel Apr 23, 2016
faeaabb
Merge branch 'feature/redux' into feature/react-intl
langpavel Apr 23, 2016
91b0982
Merge pull request #617 from langpavel/feature/react-intl
koistya Apr 24, 2016
9cf76bb
Write newline on end of messages file
langpavel Apr 25, 2016
bd587c3
Add newline before EOF
langpavel Apr 25, 2016
03bcce4
Merge pull request #620 from langpavel/feature/react-intl
koistya Apr 25, 2016
925806e
Fix linting errors (#622)
langpavel Apr 25, 2016
86e2d4b
[feature/react-intl] Fix ProvideIntl PropTypes validation (#625)
langpavel Apr 26, 2016
e0dd538
Merge branch 'master' into feature/react-intl
koistya Apr 28, 2016
68e31a6
Merge branch 'master' into feature/react-intl
koistya May 3, 2016
a8fb68a
[react-intl] Store current language in cookie (#638)
langpavel May 4, 2016
47d5bbb
[feature/react-intl] Extract `description` into messages files (#653)
langpavel May 17, 2016
21c77a8
Merge branch 'master' into feature/react-intl
koistya May 19, 2016
f649f0d
[feature/react-intl] Intl polyfill for Safari [closes #639]
langpavel May 26, 2016
a265a08
Fix lint
langpavel May 26, 2016
24204ce
Merge branch 'feature/redux' into feature/react-intl
langpavel Jul 10, 2016
0d1a01c
Merge branch 'feature/react-intl' of github.com:langpavel/react-start…
langpavel Jul 10, 2016
eb7a934
[feature/react-intl] merge feature/redux (#734)
langpavel Jul 10, 2016
c971b78
Revert "[feature/react-intl] merge feature/redux (#734)"
langpavel Jul 10, 2016
aa8a911
Merge branch 'feature-react-intl-merge-feature-redux' into feature/re…
langpavel Jul 10, 2016
a3e845c
Merge branch 'feature/redux' into feature/react-intl
langpavel Jul 10, 2016
6067241
Merge pull request #672 from langpavel/feature/react-intl
langpavel Jul 10, 2016
421970b
Merge branch 'feature/redux' into feature-react-intl-merge-feature-redux
langpavel Jul 10, 2016
c8b5047
Merge pull request #735 from langpavel/feature-react-intl-merge-featu…
langpavel Jul 10, 2016
4f66eec
Merge branch 'feature/redux' into feature/react-intl
langpavel Jul 15, 2016
a504763
Merge branch 'feature/redux' into feature/react-intl
langpavel Jul 18, 2016
60bc2c8
Merge branch 'feature/redux' into feature/react-intl
langpavel Jul 27, 2016
031c510
Merge branch 'feature/redux' into feature/react-intl
langpavel Jul 29, 2016
1dd8893
Merge branch 'feature/redux' into react-intl-merge-redux
langpavel Aug 2, 2016
bbc2f08
Merge pull request #787 from langpavel/react-intl-merge-redux
langpavel Aug 2, 2016
3c0cdd5
Better code in setLocale action
langpavel Aug 4, 2016
ee5d7e4
Merge pull request #792 from langpavel/intl-better-action
langpavel Aug 4, 2016
d24baa8
Merge branch 'feature/redux' into feature/react-intl
langpavel Aug 4, 2016
79304bd
Merge branch 'feature/redux' into feature/react-intl
langpavel Aug 4, 2016
b72965b
Merge branch 'feature/redux' into feature/react-intl
langpavel Aug 7, 2016
e63fa3f
[feature/react-intl] Convert backslashes in messages files to slashes
langpavel Aug 10, 2016
5746145
Merge pull request #798 from langpavel/react-intl-fix-win-paths
langpavel Aug 10, 2016
1cae602
Merge branch 'feature/redux' into feature/react-intl
langpavel Sep 2, 2016
04df6cf
Merge branch 'feature/redux' into feature/react-intl
langpavel Sep 4, 2016
14c616c
[feature/react-intl] Sort paths in messages
langpavel Sep 4, 2016
d808316
Merge pull request #836 from langpavel/react-intl-sort-file-names
langpavel Sep 6, 2016
2c9e069
Merge branch 'feature/redux' into feature/react-intl
langpavel Sep 6, 2016
2fa2f8f
Merge branch 'feature/redux' into feature/react-intl
langpavel Sep 12, 2016
f6b8c59
eslint
langpavel Sep 12, 2016
b211835
Allow load critical but optional polyfills
langpavel Oct 3, 2016
36efa57
Merge branch 'new-redux' into feature/redux
langpavel Oct 3, 2016
9b136da
Merge branch 'client-loader' into new-react-intl
langpavel Oct 3, 2016
a5d62a0
Merge branch 'feature/react-intl' into new-react-intl
langpavel Oct 3, 2016
0903b13
Merge pull request #895 from langpavel/new-react-intl
langpavel Oct 3, 2016
11beb27
[feature/react-intl] Better Language Switcher
langpavel Oct 4, 2016
30e2b32
Merge pull request #897 from langpavel/better-language-switcher
langpavel Oct 4, 2016
2d39a31
Fix: Error page rendering
langpavel Oct 5, 2016
f5c9a0e
Merge branch 'feature/redux' into feature/react-intl
langpavel Oct 5, 2016
bcf1d6e
Merge branch 'feature/redux' into feature/react-intl
langpavel Oct 9, 2016
d1e2b33
Add empty user reducer and clean import react.children (#899)
keremciu Oct 12, 2016
600ce7a
Merge branch 'feature/redux' into feature/react-intl
langpavel Oct 12, 2016
2517a86
Add static content intl(locale) support
awesomejerry Oct 13, 2016
deb0e72
Update intl(locale) content support
awesomejerry Oct 14, 2016
222ef57
Update intl(locale) content support
awesomejerry Oct 16, 2016
4c9b1e6
[redux] content - do not throw away old content in store on error
langpavel Oct 16, 2016
1c5210e
Content refactoring
langpavel Oct 17, 2016
c3252aa
Merge branch 'awesomejerry-react-intl/content' into feature/react-intl
langpavel Oct 17, 2016
bd48dc3
Merge branch 'feature/redux' into feature/react-intl
langpavel Oct 17, 2016
e6c7df7
Merge branch 'feature/redux' into feature/react-intl
langpavel Oct 21, 2016
79feb17
Fix test
langpavel Oct 21, 2016
ad990f3
Merge branch 'feature/redux' into feature/react-intl
langpavel Oct 21, 2016
8a1ca98
Merge branch 'feature/redux' into feature/react-intl
langpavel Oct 22, 2016
9a93f56
Merge branch 'feature/redux' into feature/react-intl
langpavel Oct 22, 2016
549dda0
Merge branch 'feature/redux' into feature/react-intl
langpavel Oct 25, 2016
c8a2003
Merge branch 'feature/redux' into feature/react-intl
langpavel Nov 2, 2016
beb4290
Merge branch 'feature/redux' into feature/react-intl
langpavel Nov 11, 2016
ebed51b
Merge branch 'feature/redux' into feature/react-intl
langpavel Dec 1, 2016
23fa725
Merge feature/redux into feature/react-intl
langpavel Dec 10, 2016
8e4bd64
Merge branch 'feature/redux' into feature/react-intl
langpavel Dec 15, 2016
94b00cf
Removed gaze dependency from extractMessages
pdeszynski Dec 16, 2016
93a0bd6
Merge pull request #1034 from piteer1/feature/react-intl
langpavel Dec 16, 2016
7f1d692
Merge branch 'feature/redux'
langpavel Dec 20, 2016
a2db319
Add css class for content route loading
langpavel Dec 20, 2016
e44f751
Merge branch 'feature/redux' into feature/react-intl
awesomejerry Jan 11, 2017
f5f829e
Merge pull request #1078 from awesomejerry/feature/react-intl
langpavel Jan 12, 2017
0aa8848
fixed news feed query (#1045)
smshuja Jan 29, 2017
caead88
updated date field name.
smshuja Jan 29, 2017
448bc52
Merge pull request #1103 from smshuja/news-feed-query-fix
langpavel Feb 1, 2017
667a387
Merge branch 'feature/redux' into feature/react-intl
langpavel Feb 1, 2017
7a6f74e
Merge branch 'feature/redux' into feature/react-intl
langpavel Feb 1, 2017
f61b39b
Merge branch 'feature/redux' into feature/react-intl
langpavel Feb 11, 2017
930f53d
Merge branch 'feature/redux' into feature/react-intl
langpavel Feb 13, 2017
dba0dd3
Merge branch 'feature/redux' into feature/react-intl
langpavel Feb 14, 2017
9514ff8
Merge branch 'feature/redux' into feature/react-intl
langpavel Feb 16, 2017
011337e
packages: apollo-client, react-apollo and graphql-tag dependencies
langpavel Feb 24, 2017
22dc950
Initial Apollo integration
langpavel Feb 24, 2017
03791e9
News now using `graphql` from react-apollo
langpavel Feb 24, 2017
c3782d8
Merge branch 'feature/apollo' into feature/react-intl
langpavel Feb 24, 2017
b4df966
seamless transition from fetch to apollo in redux helpers
langpavel Feb 24, 2017
558eb4e
Use prepared query for intl action
langpavel Feb 24, 2017
623f3a4
test: ignore .graphql and .gql imports
langpavel Feb 24, 2017
48231cf
Merge branch 'feature/redux' into feature/apollo
langpavel Feb 27, 2017
0895c21
seamless transition from fetch to apollo in redux helpers
langpavel Feb 24, 2017
d6ecb1c
Avoid using gql template tag at runtime, write handy warning if so
langpavel Feb 27, 2017
cc8c5f9
Merge branch 'feature/apollo' into feature/react-intl
langpavel Feb 27, 2017
e968732
Skip cache for intl action
langpavel Feb 28, 2017
cf42f90
Merge branch 'feature/redux' into feature/apollo
langpavel Mar 12, 2017
e48fec9
Merge branch 'feature/apollo' into feature/react-intl
langpavel Mar 13, 2017
8c3189e
Use react-deep-force-update when locale changes
langpavel Mar 13, 2017
1a7e45b
Include credentials with Apollo request
langpavel Mar 15, 2017
85b3367
Include credentials with Apollo request
langpavel Mar 15, 2017
08be6ff
Fix issue with mutations, deprecate `graphqlRequest`
langpavel Mar 16, 2017
734919a
Upgrade Apollo
langpavel Mar 16, 2017
37f1b80
Merge branch 'feature/redux' into feature/apollo
langpavel Mar 16, 2017
42a8ff0
Merge branch 'feature/apollo' into feature/react-intl
langpavel Mar 16, 2017
963ae2a
Merge branch 'feature/redux' into feature/apollo
langpavel Mar 25, 2017
77acb76
Merge branch 'feature/apollo' into feature/react-intl
langpavel Mar 25, 2017
a38aa6b
Do not log intl messages on server
langpavel Mar 25, 2017
8c856ef
Ase Apollo network layer directly to fetch messages, skipping cache
langpavel Mar 25, 2017
86132ac
change name and unify format of package.json for createApolloClient
zirho Mar 29, 2017
5a19805
Merge branch 'feature/redux' into feature/apollo
langpavel Mar 31, 2017
f48ceff
Upgrade packages
langpavel Mar 31, 2017
707dc0b
Merge branch 'feature/apollo' into feature/react-intl
langpavel Mar 31, 2017
0a2782a
fix(store/configureStore): fix hot reloader
Stupidism Apr 5, 2017
9770f63
Merge branch 'feature/redux' into feature/apollo
langpavel Apr 10, 2017
588b42a
Merge branch 'feature/apollo' into feature/react-intl
langpavel Apr 10, 2017
2156f8d
Re-route application when locale changed.
langpavel Apr 10, 2017
b62314c
Don't listen to intellisense, you will make mistake like this..
langpavel Apr 11, 2017
db6abb5
Merge branch 'feature/apollo' into feature/react-intl
langpavel Apr 11, 2017
705a39e
Merge branch 'feature/redux' into feature/apollo
langpavel Apr 16, 2017
1faa972
Merge branch 'feature/apollo' into feature/react-intl
langpavel Apr 16, 2017
54efedc
Merge branch 'feature/redux' into feature/apollo
langpavel May 23, 2017
e393804
Merge branch 'feature/apollo' into feature/react-intl
langpavel May 24, 2017
8182af7
Remove no longer used Provide component
langpavel May 25, 2017
ba4894a
Merge branch 'feature/redux' into feature/apollo
langpavel May 25, 2017
a2de349
Merge branch 'feature/apollo' into feature/react-intl
langpavel May 25, 2017
1f4f7ef
Merge branch 'feature/redux' into feature/apollo
langpavel Jun 30, 2017
da4f71f
Merge branch 'feature/redux' into feature/apollo
langpavel Jun 30, 2017
8e93b63
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jul 1, 2017
101e158
Merge branch 'feature/redux' into feature/apollo
langpavel Jul 1, 2017
36dce68
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jul 1, 2017
eace0e3
Update yarn.lock
langpavel Jul 1, 2017
6fa569e
At first, go back to idea of babel-plugin-reac-intl
langpavel Jul 2, 2017
645b7a4
Mark code which needs attention if you changing locale
langpavel Jul 2, 2017
8cb5ca5
Allow use of intl in router
langpavel Jul 2, 2017
1e21de3
Example: how to use intl in router
langpavel Jul 2, 2017
d4a9583
Re-enable build of messages
langpavel Jul 2, 2017
58a9aa5
Merge branch 'feature/redux' into feature/apollo
langpavel Jul 10, 2017
1affa66
yarn: fix react-dom issue caused by reac-apollo
langpavel Jul 10, 2017
136a3b7
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jul 10, 2017
988bbd5
tests: jest-transform-graphql
langpavel Jul 10, 2017
39d30b2
tests: jest-transform-graphql
langpavel Jul 10, 2017
28b41d4
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jul 10, 2017
38b9f67
test: update snapshot
langpavel Jul 10, 2017
2bcb7e1
Merge branch 'feature/redux' into feature/apollo
langpavel Jul 14, 2017
f86d69b
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jul 14, 2017
b429d3b
Merge branch 'feature/redux' into feature/apollo
langpavel Aug 11, 2017
e9335da
Merge branch 'feature/apollo' into feature/react-intl
langpavel Aug 11, 2017
4f7a1f5
WIP: Merge branch 'feature/redux' into feature/apollo
langpavel Aug 22, 2017
61bdcae
FIX: react-apollo now needs wider context, so delegate responsibility…
langpavel Aug 22, 2017
2d3c105
Merge branch 'feature/apollo' into feature/react-intl
langpavel Aug 22, 2017
73e7705
Fix Layout test
Oct 6, 2017
f5c85f1
Use news.graphql content as fetch body query in home route
Oct 6, 2017
1a66055
Convert function into ES6 class and add default stylesheet
colorfield Dec 11, 2017
a65988a
[feature/Apollo] Upgrade to Apollo Client 2.0 (#1492)
tim-soft Jan 5, 2018
4ce25fc
Merge branch 'feature/redux' into feature/apollo
langpavel Jan 5, 2018
bcb056b
Downgrade graphql (0.12.3 -> 0.11.7)
langpavel Jan 5, 2018
73e1b1c
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jan 6, 2018
eeac362
fix Apollo state (re)hydration
langpavel Jan 6, 2018
abe3ed2
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jan 6, 2018
37ea09b
workaround Apollo cache for intl messages
langpavel Jan 6, 2018
2f63ce9
Better way to fetch intl messages with Apollo
langpavel Jan 6, 2018
4d351f4
typos
langpavel Jan 7, 2018
8effc49
Merge branch 'feature/redux' into feature/apollo
langpavel Jan 7, 2018
0aa0a82
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jan 7, 2018
c956344
:sparkles: Log Apollo ops in development (#1496)
tim-soft Jan 8, 2018
fc81b65
Merge branch 'feature/react-intl' of https://github.com/r-daneeloliva…
langpavel Jan 8, 2018
9cb1b30
Merge branch 'r-daneelolivaw/feature/react-intl' into feature/react-intl
langpavel Jan 8, 2018
712b80a
Merge branch 'feature-apollo-single-source-of-graphql-query' of git:/…
langpavel Jan 8, 2018
ea5111e
Use apollo client in router instead of fetch
langpavel Jan 8, 2018
c8f7165
Merge branch 'KrzysztofKarol-feature-apollo-single-source-of-graphql-…
langpavel Jan 8, 2018
8764b24
Merge branch 'feature/redux' into feature/apollo
langpavel Jan 8, 2018
5c8bb28
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jan 8, 2018
9382aa2
:recycle: Implement GraphQL-Tools based Schema (#1498)
tim-soft Jan 13, 2018
d7d4187
Merge branch 'feature/redux' into feature/apollo
langpavel Jan 14, 2018
e1d5f69
Partial merge of 'feature/apollo' into feature/react-intl
langpavel Jan 14, 2018
c893015
Add intl query by new graphql-tools way
langpavel Jan 14, 2018
7373ec4
Fix errors in graphql-tools implementation (#1503)
langpavel Jan 14, 2018
b672957
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jan 14, 2018
4fb56bc
Merge branch 'feature/redux' into feature/apollo
langpavel Jan 23, 2018
ca3e9ac
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jan 23, 2018
80cac88
Merge branch 'feature/redux' into feature/apollo
langpavel Jan 31, 2018
39a8ce6
Merge branch 'feature/apollo' into feature/react-intl
langpavel Jan 31, 2018
6910350
fix: Hot module reloading
langpavel Feb 6, 2018
cd6d4bb
fix babel core usage
dreisel Feb 23, 2018
3042323
Merge branch 'feature/redux' into feature/apollo
langpavel Mar 24, 2018
d4c8bf6
chore: yarn upgrade --latest
langpavel Mar 24, 2018
6c851d3
fix(redux): createRootReducer → rootReducer
langpavel Mar 24, 2018
699f84d
Merge branch 'feature/apollo' into feature/react-intl
langpavel Mar 24, 2018
71b4412
chore: update messages
langpavel Mar 24, 2018
6dedc85
test: fix rootReducer test
langpavel Mar 24, 2018
d5cf707
Merge branch 'feature/redux' into feature/apollo
langpavel Mar 25, 2018
890839c
Merge branch 'feature/apollo' into feature/react-intl
langpavel Mar 25, 2018
f54d6f4
chore: yarn upgrade
langpavel Mar 25, 2018
4aff38b
Merge 'patch-1' of git://github.com/reisel/react-starter-kit into fea…
langpavel Mar 25, 2018
8f0fdc6
chore,style: do not process json via prettier
langpavel Mar 25, 2018
fc3bc29
bug(polyfill) - fix polyfill loading. (#1583)
dreisel Jun 19, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ module.exports = {
},
],

// Allow only special identifiers
// https://eslint.org/docs/rules/no-underscore-dangle
'no-underscore-dangle': [
'error',
{
allow: ['__typename'],
},
],

// Prefer destructuring from arrays and objects
// http://eslint.org/docs/rules/prefer-destructuring
'prefer-destructuring': [
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.formatOnPaste": true,
"editor.minimap.enabled": true,
"editor.snippetSuggestions": "top"
}
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ module.exports = {

transform: {
'\\.(js|jsx)$': '<rootDir>/node_modules/babel-jest',
'\\.(gql|graphql)$': '<rootDir>/node_modules/jest-transform-graphql',
'^(?!.*\\.(js|jsx|json|css|less|styl|scss|sass|sss)$)':
'<rootDir>/tools/lib/fileTransformer.js',
},
Expand Down
22 changes: 21 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
"browserslist": [">1%", "last 4 versions", "Firefox ESR", "not ie < 9"],
"dependencies": {
"@babel/polyfill": "^7.0.0-beta.42",
"apollo-cache-inmemory": "^1.1.4",
"apollo-client": "^2.0.4",
"apollo-link": "^1.0.7",
"apollo-link-error": "^1.0.3",
"apollo-link-http": "^1.3.2",
"apollo-link-logger": "^1.1.0",
"apollo-link-schema": "^1.0.1",
"bluebird": "^3.5.1",
"body-parser": "^1.18.2",
"classnames": "^2.2.5",
Expand All @@ -17,10 +24,16 @@
"express": "^4.16.3",
"express-graphql": "^0.6.12",
"express-jwt": "^5.3.1",
"express-request-language": "^1.1.12",
"graphql": "^0.13.2",
"graphql-tag": "^2.6.1",
"graphql-tools": "^2.16.0",
"history": "^4.7.2",
"intl": "^1.2.5",
"intl-locales-supported": "^1.0.0",
"isomorphic-style-loader": "^4.0.0",
"jsonwebtoken": "^8.2.0",
"lodash": "^4.17.5",
"node-fetch": "^2.1.1",
"normalize.css": "^8.0.0",
"passport": "^0.4.0",
Expand All @@ -29,7 +42,9 @@
"prop-types": "^15.6.1",
"query-string": "^6.0.0",
"react": "^16.2.0",
"react-apollo": "^2.0.4",
"react-dom": "^16.2.0",
"react-intl": "^2.4.0",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-devtools-extension": "^2.13.2",
Expand All @@ -56,6 +71,7 @@
"babel-eslint": "^8.2.2",
"babel-jest": "^22.4.3",
"babel-loader": "^8.0.0-beta.2",
"babel-plugin-react-intl": "^2.3.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.13",
"browser-sync": "^2.23.6",
"chokidar": "^2.0.2",
Expand All @@ -79,6 +95,9 @@
"husky": "^0.14.3",
"identity-obj-proxy": "^3.0.0",
"jest": "^22.4.3",
"jest-codemods": "^0.13.9",
"jest-transform-graphql": "^2.1.0",
"jscodeshift": "^0.5.0",
"lint-staged": "^7.0.0",
"markdown-it": "^8.4.1",
"mkdirp": "^0.5.1",
Expand Down Expand Up @@ -123,7 +142,7 @@
},
"lint-staged": {
"*.{js,jsx}": ["eslint --no-ignore --fix", "git add --force"],
"*.{json,md,graphql}": ["prettier --write", "git add --force"],
"*.{md,graphql}": ["prettier --write", "git add --force"],
"*.{css,less,styl,scss,sass,sss}": ["stylelint --fix", "git add --force"]
},
"scripts": {
Expand All @@ -142,6 +161,7 @@
"coverage": "yarn run test-cover && opn coverage/lcov-report/index.html",
"clean": "babel-node tools/run clean",
"copy": "babel-node tools/run copy",
"messages": "babel-node tools/run messages",
"bundle": "babel-node tools/run bundle",
"build": "babel-node tools/run build",
"build-stats": "yarn run build --release --analyse",
Expand Down
6 changes: 6 additions & 0 deletions src/actions/intl.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
query intl ($locale:String!) {
intl (locale:$locale) {
id
message
}
}
79 changes: 79 additions & 0 deletions src/actions/intl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* eslint-disable import/prefer-default-export */

import { IntlProvider } from 'react-intl';

import {
SET_LOCALE_START,
SET_LOCALE_SUCCESS,
SET_LOCALE_ERROR,
} from '../constants';

import queryIntl from './intl.graphql';

function getIntlFromState(state) {
const intl = (state && state.intl) || {};
const { initialNow, locale, messages } = intl;
const localeMessages = (messages && messages[locale]) || {};
const provider = new IntlProvider({
initialNow,
locale,
messages: localeMessages,
defaultLocale: 'en-US',
});
return provider.getChildContext().intl;
}

export function getIntl() {
return (dispatch, getState) => getIntlFromState(getState());
}

export function setLocale({ locale }) {
return async (dispatch, getState, { client, history }) => {
dispatch({
type: SET_LOCALE_START,
payload: {
locale,
},
});

try {
// WARNING !!
// do not use client.networkInterface except you want skip Apollo store
// use client.query if you want benefit from Apollo caching mechanisms
const { data } = await client.query({
query: queryIntl,
variables: { locale },
});
const messages = data.intl.reduce((msgs, msg) => {
msgs[msg.id] = msg.message; // eslint-disable-line no-param-reassign
return msgs;
}, {});
dispatch({
type: SET_LOCALE_SUCCESS,
payload: {
locale,
messages,
},
});

// remember locale for every new request
if (process.env.BROWSER) {
const maxAge = 3650 * 24 * 3600; // 10 years in seconds
document.cookie = `lang=${locale};path=/;max-age=${maxAge}`;
history.push(`?lang=${locale}`);
}

// return bound intl instance at the end
return getIntlFromState(getState());
} catch (error) {
dispatch({
type: SET_LOCALE_ERROR,
payload: {
locale,
error,
},
});
return null;
}
};
}
65 changes: 53 additions & 12 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,40 @@ import ReactDOM from 'react-dom';
import deepForceUpdate from 'react-deep-force-update';
import queryString from 'query-string';
import { createPath } from 'history/PathUtils';
import { addLocaleData } from 'react-intl';
// This is so bad: requiring all locale if they are not needed?
/* @intl-code-template import ${lang} from 'react-intl/locale-data/${lang}'; */
import en from 'react-intl/locale-data/en';
import cs from 'react-intl/locale-data/cs';
/* @intl-code-template-end */
import App from './components/App';
import createFetch from './createFetch';
import configureStore from './store/configureStore';
import history from './history';
import { updateMeta } from './DOMUtils';
import history from './history';
import createApolloClient from './core/createApolloClient';
import router from './router';
import { getIntl } from './actions/intl';

/* @intl-code-template addLocaleData(${lang}); */
addLocaleData(en);
addLocaleData(cs);
/* @intl-code-template-end */

// Universal HTTP client
const fetch = createFetch(window.fetch, {
baseUrl: window.App.apiUrl,
});

const apolloClient = createApolloClient();

// Initialize a new Redux store
// http://redux.js.org/docs/basics/UsageWithReact.html
const store = configureStore(window.App.state, {
apolloClient,
fetch,
history,
});

// Global (context) variables that can be easily accessed from any React component
// https://facebook.github.io/react/docs/context.html
Expand All @@ -32,14 +60,14 @@ const context = {
removeCss.forEach(f => f());
};
},
// Universal HTTP client
fetch: createFetch(fetch, {
baseUrl: window.App.apiUrl,
}),
// Initialize a new Redux store
// http://redux.js.org/docs/basics/UsageWithReact.html
store: configureStore(window.App.state, { history }),
// For react-apollo
client: apolloClient,
store,
storeSubscription: null,
// Universal HTTP client
fetch,
// intl instance as it can be get with injectIntl
intl: store.dispatch(getIntl()),
};

const container = document.getElementById('app');
Expand All @@ -61,10 +89,13 @@ async function onLocationChange(location, action) {
}
currentLocation = location;

context.intl = store.dispatch(getIntl());

const isInitialRender = !action;
try {
context.pathname = location.pathname;
context.query = queryString.parse(location.search);
context.locale = store.getState().intl.locale;

// Traverses the list of routes in the order they are defined until
// it finds the first route that matches provided URL path string
Expand Down Expand Up @@ -151,10 +182,20 @@ async function onLocationChange(location, action) {
}
}

// Handle client-side navigation by using HTML5 History API
// For more information visit https://github.com/mjackson/history#readme
history.listen(onLocationChange);
onLocationChange(currentLocation);
let isHistoryObserved = false;
export default function main() {
// Handle client-side navigation by using HTML5 History API
// For more information visit https://github.com/mjackson/history#readme
currentLocation = history.location;
if (!isHistoryObserved) {
isHistoryObserved = true;
history.listen(onLocationChange);
}
onLocationChange(currentLocation);
}

// globally accesible entry point
window.RSK_ENTRY = main;

// Enable Hot Module Replacement (HMR)
if (module.hot) {
Expand Down
43 changes: 43 additions & 0 deletions src/clientLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const readyStates = new Set(['complete', 'loaded', 'interactive']);

function loadMainClient() {
const main = require('./client').default; // eslint-disable-line global-require
main();
}

function run() {
// Run the application when both DOM is ready and page content is loaded
if (readyStates.has(document.readyState) && document.body) {
loadMainClient();
} else {
document.addEventListener('DOMContentLoaded', loadMainClient, false);
}
}

if (!global.Intl) {
// You can show loading banner here

require.ensure(
[
// Add all large polyfills here
'intl',
/* @intl-code-template 'intl/locale-data/jsonp/${lang}.js', */
'intl/locale-data/jsonp/en.js',
'intl/locale-data/jsonp/cs.js',
/* @intl-code-template-end */
],
require => {
// and require them here
require('intl');
// TODO: This is bad. You should only require one language dynamically
/* @intl-code-template require('intl/locale-data/jsonp/${lang}.js'); */
require('intl/locale-data/jsonp/en.js');
require('intl/locale-data/jsonp/cs.js');
/* @intl-code-template-end */
run();
},
'polyfills',
);
} else {
run();
}
Loading