-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
117 additions
and
45 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import getValue from './utils/getValue'; | ||
import formatMessage from './formatMessage'; | ||
|
||
export default (intl) => ({ | ||
function createIntlObject(intl) { | ||
return { | ||
formatMessage: formatMessage(intl), | ||
locale: intl.locale | ||
}); | ||
locale: getValue(intl, 'locale') | ||
} | ||
} | ||
|
||
export default createIntlObject; |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
import isImmutable from './utils/isImmutable'; | ||
import {UPDATE_ACTION} from './constants'; | ||
|
||
export const initialState = () => ({ | ||
cacheDisable: false, | ||
ecmaSupport: false, | ||
locale: '', | ||
messages: {} | ||
}); | ||
function initialState() { | ||
return { | ||
cacheDisable: false, | ||
ecmaSupport: false, | ||
locale: '', | ||
messages: {} | ||
} | ||
} | ||
|
||
function setImmutable(state, payload) { | ||
return state.merge(payload); | ||
} | ||
|
||
export function intlReducer(state = initialState(), action = {}) { | ||
function intlReducer(state = initialState(), action = {}) { | ||
|
||
if (action && action.type === UPDATE_ACTION) { | ||
return { | ||
...state, | ||
...action.payload | ||
}; | ||
if (!action || action.type !== UPDATE_ACTION) { | ||
return state; | ||
} | ||
|
||
return state; | ||
if (isImmutable(state)) { | ||
return setImmutable(state, action.payload); | ||
} | ||
|
||
return { | ||
...state, | ||
...action.payload | ||
} | ||
} | ||
|
||
export {initialState as initialState}; | ||
export default intlReducer; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import get from 'lodash/get'; | ||
import isImmutable from './isImmutable'; | ||
|
||
function getMessage(state, id) { | ||
if (isImmutable(state)) { | ||
return state.getIn(['messages', id], ''); | ||
} | ||
return get(state, ['messages', id], ''); | ||
} | ||
|
||
export default getMessage; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import get from 'lodash/get'; | ||
import isImmutable from './isImmutable'; | ||
|
||
function getValue(state, value) { | ||
if (isImmutable(state)) { | ||
return state.get(value); | ||
} | ||
return get(state, value); | ||
} | ||
|
||
export default getValue; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import isFunction from 'lodash/isFunction'; | ||
|
||
function isImmutable(state = {}) { | ||
return isFunction(state.toJS); | ||
} | ||
|
||
export default isImmutable; |
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
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