fix(ott-2353): fix languages order

keep-around/aeba7be478995b14e118d787839d59ca06c0754d
nevainero 4 years ago
parent 14b5610b6b
commit aeba7be478
  1. 2
      src/config/clients/index.tsx
  2. 1
      src/config/clients/instat.tsx
  3. 12
      src/config/languages.tsx
  4. 18
      src/helpers/getSortedLangs/index.tsx

@ -3,7 +3,7 @@ import type { ClientConfig } from './types'
import { facr } from './facr'
import { instat } from './instat'
const currentClient = process.env.REACT_APP_CLIENT || 'instat'
export const currentClient = process.env.REACT_APP_CLIENT || 'instat'
const clients = {
facr,

@ -8,6 +8,7 @@ export const instat: ClientConfig = {
auth: {
clientId: ClientIds.Instat,
},
defaultLanguage: 'en',
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.Instat,

@ -1,4 +1,7 @@
export const langsList = [
import { currentClient } from 'config/clients'
import { getSortedLangs } from 'helpers/getSortedLangs'
export const langs = [
{
className: 'ru',
locale: 'ru',
@ -66,4 +69,11 @@ export const langsList = [
},
] 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']
// @ts-expect-error
export const langsList = getSortedLangs(langs)
export type Languages = typeof langsList[number]['locale']

@ -0,0 +1,18 @@
import { langsOrder } from 'config/languages'
type TLang = {
className: string,
locale: string,
title: string,
}
const getOrder = (locale: string) => (
langsOrder.findIndex((item) => item === locale)
)
export const getSortedLangs = (langs: Array<TLang>): Array<TLang> => {
langs.sort((lang1, lang2) => (
getOrder(lang1.locale) - getOrder(lang2.locale)
))
return langs
}
Loading…
Cancel
Save