本文整理匯總了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));
};