本文整理汇总了TypeScript中app/shared/reducers/locale.setLocale函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setLocale函数的具体用法?TypeScript setLocale怎么用?TypeScript setLocale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setLocale函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: async
export const getSession = () => async (dispatch, getState) => {
await dispatch({
type: ACTION_TYPES.GET_SESSION,
payload: axios.get('api/account')
});
const { account } = getState().authentication;
if (account && account.langKey) {
const langKey = Storage.session.get('locale', account.langKey);
await dispatch(setLocale(langKey));
}
};
开发者ID:gjik911,项目名称:git_01,代码行数:12,代码来源:authentication.ts
示例2: async
export const login = (username, password, rememberMe = false) => async (dispatch, getState) => {
const result = await dispatch({
type: ACTION_TYPES.LOGIN,
payload: axios.post('auth/login', { username, password })
});
await dispatch(getSession());
const account = getState().authentication.account;
if (account && account.langKey) {
await dispatch(setLocale(account.langKey));
}
};
开发者ID:gjik911,项目名称:git_01,代码行数:12,代码来源:authentication.ts
示例3: 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));
}
};
开发者ID:gjik911,项目名称:git_01,代码行数:15,代码来源:settings.reducer.ts
示例4: it
it('dispatches SET_LOCALE action for default locale', async () => {
TranslatorContext.setDefaultLocale('en');
const defaultLocale = TranslatorContext.context.defaultLocale;
expect(Object.keys(TranslatorContext.context.translations)).not.toContainEqual(defaultLocale);
const expectedActions = [
{
type: ACTION_TYPES.SET_LOCALE,
locale: defaultLocale
}
];
await store.dispatch(setLocale(defaultLocale)).then(() => {
expect(store.getActions()).toEqual(expectedActions);
expect(TranslatorContext.context.translations).toBeDefined();
expect(Object.keys(TranslatorContext.context.translations)).toContainEqual(defaultLocale);
});
});
开发者ID:gjik911,项目名称:git_01,代码行数:18,代码来源:locale.spec.ts
示例5:
export const registerLocale = store => {
store.dispatch(setLocale(Storage.session.get('locale', 'zh-cn')));
};
开发者ID:gjik911,项目名称:git_01,代码行数:3,代码来源:translation.ts
注:本文中的app/shared/reducers/locale.setLocale函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论