-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
115 lines (104 loc) · 4.29 KB
/
Copy pathscript.js
File metadata and controls
115 lines (104 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// ===== Translations =====
const translations = {
ar: {
name: 'ياسر الحربي',
bio: 'أبني أدوات… أحيانًا بدون سبب واضح 😁',
twitter_title: 'تويتر / إكس',
telegram_title: 'تيليجرام',
github_title: 'قيت هوب',
support_title: 'دعم مادي',
footer: '© 2026 YASSER ALHARBI',
langLabel: 'EN',
tutorials_title: 'شروحات',
real_debrid_tutorial: 'شرح Real-Debrid و Stremio',
aiostreams_tutorial: 'شرح إضافة AIOStreams',
subtitles_tutorial: 'حل مشاكل الترجمة',
posters_tutorial: 'تعريب البوسترات',
youtube_tutorial: 'إضافة اليوتيوب',
comet_tutorial: 'شرح إضافة Comet',
lg_tv_tutorial: 'شرح شاشات LG',
better_poster_tutorial: 'تحسين بوسترات Stremio',
works_title: 'أعمالي',
stremiohub_title: 'StremioHub',
stremiohub_desc: 'إدارة مكتبتك في Stremio وإضافة المحتوى بنقرة واحدة من مواقع التقييم.',
letterstremio_title: 'LetterStremio',
letterstremio_desc: 'إضافة تتيح لك إضافة زر "مشاهدة على Stremio" في موقع Letterboxd.',
letternuvio_title: 'LetterNuvio',
letternuvio_desc: 'إضافة تتيح لك حفظ أي فيلم في Nuvio بضغطة زر من داخل موقع Letterboxd.',
syncbridge_title: 'SyncBridge',
syncbridge_desc: 'مزامنة إضافات Stremio إلى Nuvio بلمسة واحدة.',
privacy_title: 'سياسة الخصوصية',
privacy_desc: 'اقرأ التزامنا بحماية بياناتك وخصوصيتك.',
},
en: {
name: 'YASSER ALHARBI',
bio: 'I build tools… sometimes for no clear reason 😁',
twitter_title: 'Twitter / X',
telegram_title: 'Telegram',
github_title: 'GitHub',
support_title: 'Support Me',
footer: '© 2026 YASSER ALHARBI',
langLabel: 'ع',
tutorials_title: 'Tutorials',
real_debrid_tutorial: 'Real-Debrid & Stremio Guide',
aiostreams_tutorial: 'AIOStreams Addon Guide',
subtitles_tutorial: 'Subtitles & Sync Guide',
posters_tutorial: 'Arabic Posters Guide',
youtube_tutorial: 'YouTube Addon Guide',
comet_tutorial: 'Comet Addon Guide',
lg_tv_tutorial: 'LG TV Stremio Setup',
better_poster_tutorial: 'Better Stremio Posters',
works_title: 'My Projects',
stremiohub_title: 'StremioHub',
stremiohub_desc: 'Add movies and shows to your Stremio library directly from IMDb, Letterboxd, and Trakt.',
letterstremio_title: 'LetterStremio',
letterstremio_desc: 'Adds a "Watch on Stremio" button to Letterboxd pages.',
letternuvio_title: 'LetterNuvio',
letternuvio_desc: 'Save any movie to Nuvio with a single click directly from Letterboxd.',
syncbridge_title: 'SyncBridge',
syncbridge_desc: 'Sync Stremio addons to Nuvio with one click.',
privacy_title: 'Privacy Policy',
privacy_desc: 'Read our commitment to your data security and privacy.',
},
};
// ===== State =====
let currentLang = 'ar';
// ===== DOM =====
const html = document.documentElement;
const langToggle = document.getElementById('langToggle');
const langLabel = document.getElementById('langLabel');
// ===== Functions =====
function applyLanguage(lang) {
currentLang = lang;
const t = translations[lang];
// Set direction and lang attribute
html.setAttribute('lang', lang);
html.setAttribute('dir', lang === 'ar' ? 'rtl' : 'ltr');
// Update all translatable elements
document.querySelectorAll('[data-i18n]').forEach((el) => {
const key = el.getAttribute('data-i18n');
if (t[key]) {
el.textContent = t[key];
}
});
// Update toggle label
langLabel.textContent = t.langLabel;
// Save preference
localStorage.setItem('preferred-lang', lang);
}
function toggleLanguage() {
applyLanguage(currentLang === 'ar' ? 'en' : 'ar');
}
function detectLanguage() {
// Check saved preference first
const saved = localStorage.getItem('preferred-lang');
if (saved && translations[saved]) {
return saved;
}
// Auto-detect from browser
const browserLang = navigator.language || navigator.userLanguage || '';
return browserLang.startsWith('ar') ? 'ar' : 'en';
}
// ===== Init =====
langToggle.addEventListener('click', toggleLanguage);
applyLanguage(detectLanguage());