Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

691 B
Raw Blame
import { DEFAULT_LANG } from '@/const/locale';
import { type Locales } from '@/locales/resources';
import { getSystemLanguage } from '@/utils/client/systemLanguage';
import { isOnServerSide } from '@/utils/env';

import { type GlobalState } from '../initialState';
import { systemStatus } from './systemStatus';

const language = (s: GlobalState) => systemStatus(s).language || 'auto';

const currentLanguage = (s: GlobalState) => {
  const locale = language(s);

  if (locale === 'auto') {
    if (isOnServerSide) return DEFAULT_LANG;

    return getSystemLanguage() as Locales;
  }

  return locale as Locales;
};

export const globalGeneralSelectors = {
  currentLanguage,
  language,
};