import { Translation } from '@/api/resources/Translations.ts' import { Translations } from '../api' import dev from './dev.ts' export const getClientLocale = () => navigator.language.split('-')[0] export const getClientTimezone = () => Intl.DateTimeFormat().resolvedOptions().timeZone export const fallbackLng = 'dev' const omitKeys = ['href', 'title', 'url_slug', 'type'] // const isWeb = (group: Elements.ElementGroup) => group.name === 'web' const cleanUp = (translation: Partial = []) => { return translation .filter((trans) => !omitKeys.includes(trans?.key || '')) .reduce((acc, trans) => ({ ...acc, [trans?.key || '']: trans?.value || '' }), {}) } export const buildResources = (resp: Translations.Response) => { const element = resp.translations const translation = cleanUp(element) const lng = getClientLocale() return { [lng]: { translation }, dev } }