Rename and convert dfnshelper to typescript
This commit is contained in:
parent
b3febe49ad
commit
1473a793e5
7 changed files with 10 additions and 10 deletions
|
@ -3,12 +3,12 @@ import Events from '../utils/events.ts';
|
|||
import globalize from '../scripts/globalize';
|
||||
import dom from '../scripts/dom';
|
||||
import { formatRelative } from 'date-fns';
|
||||
import { getLocale } from '../scripts/dfnshelper';
|
||||
import serverNotifications from '../scripts/serverNotifications';
|
||||
import '../elements/emby-button/emby-button';
|
||||
import './listview/listview.scss';
|
||||
import ServerConnections from './ServerConnections';
|
||||
import alert from './alert';
|
||||
import { getLocale } from '../utils/dateFnsLocale.ts';
|
||||
import { toBoolean } from '../utils/string.ts';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { UserDto } from '@jellyfin/sdk/lib/generated-client';
|
||||
import React, { FunctionComponent } from 'react';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { getLocaleWithSuffix } from '../../../scripts/dfnshelper';
|
||||
import { getLocaleWithSuffix } from '../../../utils/dateFnsLocale';
|
||||
import globalize from '../../../scripts/globalize';
|
||||
import cardBuilder from '../../cardbuilder/cardBuilder';
|
||||
import IconButtonElement from '../../../elements/IconButtonElement';
|
||||
|
|
|
@ -6,7 +6,7 @@ import serverNotifications from '../../scripts/serverNotifications';
|
|||
import dom from '../../scripts/dom';
|
||||
import globalize from '../../scripts/globalize';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { getLocaleWithSuffix } from '../../scripts/dfnshelper';
|
||||
import { getLocaleWithSuffix } from '../../utils/dateFnsLocale.ts';
|
||||
import loading from '../../components/loading/loading';
|
||||
import playMethodHelper from '../../components/playback/playmethodhelper';
|
||||
import cardBuilder from '../../components/cardbuilder/cardBuilder';
|
||||
|
|
|
@ -5,7 +5,7 @@ import dom from '../../../scripts/dom';
|
|||
import globalize from '../../../scripts/globalize';
|
||||
import imageHelper from '../../../scripts/imagehelper';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { getLocaleWithSuffix } from '../../../scripts/dfnshelper';
|
||||
import { getLocaleWithSuffix } from '../../../utils/dateFnsLocale.ts';
|
||||
import '../../../elements/emby-button/emby-button';
|
||||
import '../../../elements/emby-itemscontainer/emby-itemscontainer';
|
||||
import '../../../components/cardbuilder/card.scss';
|
||||
|
|
|
@ -3,7 +3,7 @@ import loading from '../../../components/loading/loading';
|
|||
import globalize from '../../../scripts/globalize';
|
||||
import serverNotifications from '../../../scripts/serverNotifications';
|
||||
import { formatDistance, formatDistanceToNow } from 'date-fns';
|
||||
import { getLocale, getLocaleWithSuffix } from '../../../scripts/dfnshelper';
|
||||
import { getLocale, getLocaleWithSuffix } from '../../../utils/dateFnsLocale.ts';
|
||||
import Events from '../../../utils/events.ts';
|
||||
|
||||
import '../../../components/listview/listview.scss';
|
||||
|
|
|
@ -2,7 +2,7 @@ import isEmpty from 'lodash-es/isEmpty';
|
|||
|
||||
import { currentSettings as userSettings } from './settings/userSettings';
|
||||
import Events from '../utils/events.ts';
|
||||
import { updateLocale } from './dfnshelper';
|
||||
import { updateLocale } from '../utils/dateFnsLocale.ts';
|
||||
|
||||
const Direction = {
|
||||
rtl: 'rtl',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import enUS from 'date-fns/locale/en-US';
|
||||
|
||||
const LOCALE_MAP = {
|
||||
const LOCALE_MAP: Record<string, string> = {
|
||||
'af': 'af',
|
||||
'ar': 'ar-DZ',
|
||||
'be-by': 'be',
|
||||
|
@ -67,10 +67,10 @@ const DEFAULT_LOCALE = 'en-US';
|
|||
let localeString = DEFAULT_LOCALE;
|
||||
let locale = enUS;
|
||||
|
||||
export async function updateLocale(newLocale) {
|
||||
console.debug('[dfnshelper] updating date-fns locale', newLocale);
|
||||
export async function updateLocale(newLocale: string) {
|
||||
console.debug('[dateFnsLocale] updating date-fns locale', newLocale);
|
||||
localeString = LOCALE_MAP[newLocale] || LOCALE_MAP[newLocale.replace(/-.*/, '')] || DEFAULT_LOCALE;
|
||||
console.debug('[dfnshelper] mapped to date-fns locale', localeString);
|
||||
console.debug('[dateFnsLocale] mapped to date-fns locale', localeString);
|
||||
locale = await import(`date-fns/locale/${localeString}/index.js`);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue