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
+6 -39
View File
@@ -4,6 +4,10 @@
*/
import type { AudioTrack, VideoQuality } from '../types'
import { getTranslations, detectBrowserLanguage } from '../i18n'
// Re-export control functions for backward compatibility
export { setHlsQualityLevel, setHlsAudioTrack } from './hlsControl'
const HLS_CDN_URL = 'https://cdn.jsdelivr.net/npm/hls.js@1.5.13/dist/hls.min.js'
@@ -119,6 +123,7 @@ export const getHlsQualities = (hls: any): VideoQuality[] => {
? resolution.split('x').map((value: string) => parseInt(value, 10))
: [undefined, undefined]
const translations = getTranslations(detectBrowserLanguage());
const width = level.width || widthFromResolution
const height = level.height || heightFromResolution
const bitrate = typeof level.bitrate === 'number' ? level.bitrate : level.attrs?.BANDWIDTH
@@ -131,7 +136,7 @@ export const getHlsQualities = (hls: any): VideoQuality[] => {
} else if (typeof bitrate === 'number' && bitrate > 0) {
label = `${Math.round(bitrate / 1000)} kbps`
} else {
label = `Seviye ${index + 1}`
label = `${translations.level} ${index + 1}`
}
return {
@@ -156,41 +161,3 @@ export const getHlsQualities = (hls: any): VideoQuality[] => {
}
}
/**
* Update active quality level in HLS instance. Passing null re-enables auto.
*/
export const setHlsQualityLevel = (hls: any, levelIndex: number | null | undefined): void => {
if (!hls || !Array.isArray(hls.levels)) {
return
}
if (levelIndex === null || typeof levelIndex === 'undefined' || levelIndex < 0) {
if (hls.currentLevel !== -1) {
hls.currentLevel = -1
}
return
}
if (levelIndex >= hls.levels.length) {
return
}
if (hls.currentLevel !== levelIndex) {
hls.currentLevel = levelIndex
}
}
/**
* Set active audio track in HLS instance
*/
export const setHlsAudioTrack = (hls: any, audioTrackIndex: number): void => {
if (!hls || !hls.audioTracks) {
return
}
if (audioTrackIndex < 0 || audioTrackIndex >= hls.audioTracks.length) {
return
}
hls.audioTrack = audioTrackIndex
}