-
Notifications
You must be signed in to change notification settings - Fork 2k
/
actions.js
45 lines (39 loc) · 964 Bytes
/
actions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* External dependencies
*/
import switchLocale from 'lib/i18n-utils/switch-locale';
import i18n from 'i18n-calypso';
/**
* Internal dependencies
*/
import { LOCALE_SET } from 'state/action-types';
/**
* Set the ui locale
*
* @param {String} localeSlug the locale slug to change the locale to
* @param {String?} localeVariant the slug of the variant of localeSlug
* @returns {Object} Action
*/
export const setLocale = ( localeSlug, localeVariant = null ) => {
switchLocale( localeVariant || localeSlug );
return {
type: LOCALE_SET,
localeSlug,
localeVariant,
};
};
/**
* Set the ui locale using a raw (jed) translation object
*
* @param {Object} localeData the locale data to be set
* @returns {Object} Action
*/
export const setLocaleRawData = localeData => {
i18n.setLocale( localeData );
const { localeSlug, localeVariant = null } = localeData[ '' ];
return {
type: LOCALE_SET,
localeSlug,
localeVariant,
};
};