diff --git a/src/config/clients/lff.tsx b/src/config/clients/lff.tsx index 4f26f3e2..07abbd2d 100644 --- a/src/config/clients/lff.tsx +++ b/src/config/clients/lff.tsx @@ -9,7 +9,7 @@ export const lff: ClientConfig = { auth: { clientId: ClientIds.Lff, }, - defaultLanguage: 'en', + defaultLanguage: 'lv', description: 'Live sports streaming platform. Football, basketball, ice hockey and more. Access to various player playlists and game highlights. Multiple subscription options. Available across all devices.', disabledPreferences: true, name: ClientNames.Lff, diff --git a/src/config/languages.tsx b/src/config/languages.tsx index e6d752f0..a78070cd 100644 --- a/src/config/languages.tsx +++ b/src/config/languages.tsx @@ -1,4 +1,5 @@ -import { currentClient } from 'config/clients' +import map from 'lodash/map' + import { getSortedLangs } from 'helpers/getSortedLangs' export const langs = [ @@ -67,11 +68,21 @@ export const langs = [ locale: 'bg', title: 'Български', }, + { + className: 'lv', + locale: 'lv', + title: 'latviešu', + }, ] as const -export const langsOrder = currentClient === 'instat' - ? ['en', 'bg', 'cs', 'fr', 'de', 'nl', 'it', 'es', 'pl', 'pt', 'ru', 'uk', 'zh'] - : ['cs', 'en', 'bg', 'fr', 'de', 'nl', 'it', 'es', 'pl', 'pt', 'ru', 'uk', 'zh'] +export const getLangsOrder = () => { + const commonLangsLocaleList = map(langs, (lang) => lang.locale).sort() + const clientLanglocaleIndex = commonLangsLocaleList.findIndex( + (locale) => locale === 'en', + ) + commonLangsLocaleList.splice(clientLanglocaleIndex, 1).unshift('en') + return commonLangsLocaleList +} // @ts-expect-error export const langsList = getSortedLangs(langs) diff --git a/src/features/AuthServiceApp/components/LanguageSelect/styled.tsx b/src/features/AuthServiceApp/components/LanguageSelect/styled.tsx index bc9278da..84f2f209 100644 --- a/src/features/AuthServiceApp/components/LanguageSelect/styled.tsx +++ b/src/features/AuthServiceApp/components/LanguageSelect/styled.tsx @@ -122,6 +122,7 @@ const flagPositions: Record = { fr: { col: 1, row: 4 }, gb: { col: 4, row: 12 }, it: { col: 8, row: 5 }, + lv: { col: 6, row: 6 }, nl: { col: 5, row: 8 }, pl: { col: 4, row: 9 }, pt: { col: 5, row: 9 }, diff --git a/src/features/HeaderFilters/components/DatePicker/hooks.tsx b/src/features/HeaderFilters/components/DatePicker/hooks.tsx index 18584ae9..000d9109 100644 --- a/src/features/HeaderFilters/components/DatePicker/hooks.tsx +++ b/src/features/HeaderFilters/components/DatePicker/hooks.tsx @@ -3,6 +3,7 @@ import { useEffect } from 'react' import ru from 'date-fns/locale/ru' import en from 'date-fns/locale/en-GB' import cs from 'date-fns/locale/cs' +import lv from 'date-fns/locale/lv' import { registerLocale, setDefaultLocale } from 'react-datepicker' @@ -19,6 +20,7 @@ export const useDatepickerLocales = () => { registerLocale('ru', ru) registerLocale('en', en) registerLocale('cs', cs) + registerLocale('lv', lv) }, []) useEffect(() => { diff --git a/src/helpers/getSortedLangs/index.tsx b/src/helpers/getSortedLangs/index.tsx index 1b92e767..70920fec 100644 --- a/src/helpers/getSortedLangs/index.tsx +++ b/src/helpers/getSortedLangs/index.tsx @@ -1,4 +1,4 @@ -import { langsOrder } from 'config/languages' +import { getLangsOrder } from 'config/languages' type TLang = { className: string, @@ -6,9 +6,10 @@ type TLang = { title: string, } -const getOrder = (locale: string) => ( - langsOrder.findIndex((item) => item === locale) -) +const getOrder = (locale: string) => { + const langsOrder = getLangsOrder() + return langsOrder.findIndex((item) => item === locale) +} export const getSortedLangs = (langs: Array): Array => { langs.sort((lang1, lang2) => ( diff --git a/src/helpers/isSupportedLang/__tests__/index.tsx b/src/helpers/isSupportedLang/__tests__/index.tsx index 2e915260..48a17a52 100644 --- a/src/helpers/isSupportedLang/__tests__/index.tsx +++ b/src/helpers/isSupportedLang/__tests__/index.tsx @@ -4,6 +4,7 @@ it('returns true for supported languages', () => { expect(isSupportedLang('ru')).toBe(true) expect(isSupportedLang('en')).toBe(true) expect(isSupportedLang('cs')).toBe(true) + expect(isSupportedLang('lv')).toBe(true) expect(isSupportedLang('uk')).toBe(true) expect(isSupportedLang('fr')).toBe(true) expect(isSupportedLang('de')).toBe(true)