Comments (2)
+1
I have a middleware to show notifications and this is outside of react control.
import Notifications from "react-notification-system-redux"
import {
PROFILE_UPDATE_PASSWORD_SUCCESS,
PROFILE_UPDATE_CONTACT_SUCCESS,
} from "../constants"
export default function notificationMiddleware(store) {
return next => action => {
let options
let level
switch (action.type) {
case PROFILE_UPDATE_PASSWORD_SUCCESS:
options = {
title: "Success!",
message: "Password has been successfully changed.",
position: "tr",
}
level = "success"
break
case PROFILE_UPDATE_CONTACT_SUCCESS:
options = {
title: "Success!",
message: "Contact details have been successfully modified.",
position: "tr",
}
level = "success"
break
default:
options = null
}
if (options) {
store.dispatch(Notifications.show(options, level))
}
next(action)
}
}
Any clever way to translate those messages, and keeping this as a middleware?
from redux-i18n.
In middleware I was able to access translate function with:
import { getTranslateFunction } from "redux-i18n"
export default function notificationMiddleware({ dispatch, getState }) {
return next => action => {
const { i18nState } = getState()
const translate = getTranslateFunction(i18nState.translations, i18nState.lang, "en")
(...)
from redux-i18n.
Related Issues (20)
- this.context.t is not a function react native 0.60.0 HOT 1
- Warning: componentWillMount has been renamed, and is not recommended for use HOT 1
- Reducer TypeScript definitition for combineReducers HOT 2
- doesn't work with react-native 0.64.2 HOT 1
- a vulnerability CVE-2020-7598 is introduced in redux-i18n HOT 7
- Translated strings don't rerender when new translations are set HOT 1
- Not working in react 18, <I18n /> component does not accept children HOT 2
- comment argument doesn't work
- How to get the translate function in js files that aren't components HOT 5
- [Error][object Object] html-object-as-parameter HOT 2
- Redux-i18n accessing t() function outside React components, e.g. in action creators HOT 1
- Pluralization rules per language
- this.context.t is not a function HOT 2
- Generic type 'ThunkAction' requires 4 type argument(s). HOT 4
- how to pass to setLanguage to mapDispatchToProps HOT 1
- unwanted init of redux-i18n when page refreshes HOT 1
- Dynamic Fallback language when field doesn't exist. HOT 1
- Not able to call the t function from outside utility.
- override the default state HOT 1
- Why initialLang is not taken from state?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-i18n.