1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-24 04:13:27 +02:00
metamask-extension/ui/app/ducks/locale/locale.js
Mark Stacey 2b6aff535e
Migrate "i18n-provider" to new context API (#8213)
The "i18n-provider" module has been replaced by a new `i18n.js` module
in the `contexts` directory which provides the `t` function via the new
React Context API.

The legacy context API is still used throughout the codebase, so a
legacy context provider has also been added as a shim until we migrate
away from the old API. The migration does require changing every single
place where the `t` function is used, so it is a non-trivial amount of
work. This shim allows us to tackle it one piece at a time without
breaking anything.

This was placed in a new `contexts` directory because it didn't seem
to belong in any existing categories. It certainly isn't a higher-order
component.
2020-03-23 14:07:05 -03:00

18 lines
459 B
JavaScript

import { actionConstants } from '../../store/actions'
export default function reduceLocaleMessages (state = {}, { type, value }) {
switch (type) {
case actionConstants.SET_CURRENT_LOCALE:
return {
...state,
current: value.messages,
}
default:
return state
}
}
export const getCurrentLocaleMessages = (state) => state.localeMessages.current
export const getEnLocaleMessages = (state) => state.localeMessages.en