本文整理汇总了TypeScript中react-jhipster.translate函数的典型用法代码示例。如果您正苦于以下问题:TypeScript translate函数的具体用法?TypeScript translate怎么用?TypeScript translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了translate函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: translate
export const savePassword = (currentPassword, newPassword) => ({
type: ACTION_TYPES.UPDATE_PASSWORD,
payload: axios.post(`${apiUrl}/change-password`, { currentPassword, newPassword }),
meta: {
successMessage: translate('password.messages.success'),
errorMessage: translate('password.messages.error')
}
});
示例2: translate
export const handlePasswordResetInit = mail => ({
type: ACTION_TYPES.RESET_PASSWORD_INIT,
// If the content-type isn't set that way, axios will try to encode the body and thus modify the data sent to the server.
payload: axios.post(`${apiUrl}/init`, mail, { headers: { ['Content-Type']: 'text/plain' } }),
meta: {
successMessage: translate('reset.request.messages.success'),
errorMessage: translate('reset.request.messages.notfound')
}
});
示例3: translate
export const handleRegister = (login, email, password, langKey = 'en') => ({
type: ACTION_TYPES.CREATE_ACCOUNT,
payload: axios.post('api/register', { login, email, password, langKey }),
meta: {
successMessage: translate('register.messages.success')
}
});
示例4: dispatch
export const saveAccountSettings = account => async dispatch => {
await dispatch({
type: ACTION_TYPES.UPDATE_ACCOUNT,
payload: axios.post(apiUrl, account),
meta: {
successMessage: translate('settings.messages.success')
}
});
dispatch(getSession());
};
示例5: async
export const saveAccountSettings = account => async (dispatch, getState) => {
await dispatch({
type: ACTION_TYPES.UPDATE_ACCOUNT,
payload: axios.post(apiUrl, account),
meta: {
successMessage: translate('settings.messages.success')
}
});
if (Storage.session.get(`locale`)) {
Storage.session.remove(`locale`);
}
await dispatch(getSession());
};
示例6: async
export const saveAccountSettings = account => async (dispatch, getState) => {
await dispatch({
type: ACTION_TYPES.UPDATE_ACCOUNT,
payload: axios.post(apiUrl, account),
meta: {
successMessage: translate('settings.messages.success')
}
});
await dispatch(getSession());
const accountState = getState().authentication.account;
if (accountState && accountState.langKey) {
await dispatch(setLocale(accountState.langKey));
}
};
示例7: if
.then(response => {
if (action.meta && action.meta.successMessage) {
toast.success(action.meta.successMessage);
} else if (response && response.action && response.action.payload && response.action.payload.headers) {
const headers = response.action.payload.headers;
let alert: string = null;
let alertParams: string = null;
Object.entries(headers).forEach(([k, v]: [string, string]) => {
if (k.endsWith('app-alert')) {
alert = v;
} else if (k.endsWith('app-params')) {
alertParams = v;
}
});
if (alert) {
const alertParam = alertParams;
toast.success(translate(alert, { param: alertParam }));
}
}
return Promise.resolve(response);
})
示例8:
const addErrorAlert = (message, key?, data?) => {
key = key ? key : message;
toast.error(translate(key, data));
};