UNPKG

697 BJavaScriptView Raw
1/**
2 * 从当前的 Redux state 中获取语言列表字符串
3 * 如果 uri search 中存在 fb_locale,将该值放在第一位
4 *
5 * @param {object} state 当前的 Redux state
6 *
7 * @returns {string} 语言列表,使用分号(;)分割
8 */
9export const getLanguagelistFromState = ({
10 server = {},
11 routing
12}) => {
13 const fb_locale = (
14 routing &&
15 routing.locationBeforeTransitions &&
16 routing.locationBeforeTransitions.query
17 ) ? routing.locationBeforeTransitions.query.fb_locale : null
18
19 let lang = server.lang
20 if (fb_locale) lang = fb_locale + ';' + lang
21
22 return lang || ''
23}
24
25export default getLanguagelistFromState