Add i18n, tests, and update documentation

Introduces internationalization (i18n) support with English and Turkish, adds unit tests and test setup with Vitest and React Testing Library, and updates documentation including README and changelog. Removes legacy publishing and usage guides, refactors components to use translation system, and updates build and test scripts in package.json. Also adds new utility modules for HLS and CORS, and improves PlayerContext and SettingsMenu for language support.
This commit is contained in:
hibna
2025-10-29 13:10:07 +03:00
parent e75d241421
commit bad1cc6ca0
26 changed files with 1843 additions and 1341 deletions
+9
View File
@@ -1,5 +1,7 @@
import React, { createContext, useContext, useRef, useState, useCallback } from 'react'
import type { PlayerContextValue, VideoState, UIState, PlayerSettings, AudioTrack } from '../types'
import type { Translations } from '../i18n'
import { getTranslations, detectBrowserLanguage } from '../i18n'
type SelectedQuality = PlayerSettings['quality']
type SelectedSubtitle = PlayerSettings['subtitle']
@@ -7,6 +9,7 @@ type SelectedSubtitle = PlayerSettings['subtitle']
interface PlayerContextType extends PlayerContextValue {
setVideoState: React.Dispatch<React.SetStateAction<VideoState>>
setUIState: React.Dispatch<React.SetStateAction<UIState>>
translations: Translations
}
const PlayerContext = createContext<PlayerContextType | null>(null)
@@ -25,6 +28,7 @@ interface PlayerProviderProps {
initialVolume?: number
initialMuted?: boolean
initialPlaybackRate?: number
language?: string
}
export const PlayerProvider: React.FC<PlayerProviderProps> = ({
@@ -32,10 +36,14 @@ export const PlayerProvider: React.FC<PlayerProviderProps> = ({
initialVolume = 1,
initialMuted = false,
initialPlaybackRate = 1,
language,
}) => {
const videoRef = useRef<HTMLVideoElement | null>(null)
const containerRef = useRef<HTMLDivElement | null>(null)
// Get translations based on language prop or browser language
const translations = getTranslations(language || detectBrowserLanguage())
const [videoState, setVideoState] = useState<VideoState>({
playing: false,
currentTime: 0,
@@ -169,6 +177,7 @@ export const PlayerProvider: React.FC<PlayerProviderProps> = ({
containerRef,
setVideoState,
setUIState,
translations,
play,
pause,
togglePlay,