mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
refactor: Change default uiMode from 'OVERLAY' to 'NATIVE'.
This commit is contained in:
parent
f23510a475
commit
92ca1636ee
2 changed files with 9 additions and 18 deletions
|
|
@ -40,9 +40,7 @@ const ClickActionHandler = {
|
|||
// Convert 3-letter language code to 2-letter code for Google Translate
|
||||
convertLangCode(code) {
|
||||
if (!code || code === 'auto') return code;
|
||||
// If already 2-letter code, return as is
|
||||
if (code.length === 2) return code;
|
||||
// Convert 3-letter to 2-letter, fallback to original if not found
|
||||
return LANG_CODE_MAP[code.toLowerCase()] || code;
|
||||
},
|
||||
|
||||
|
|
@ -90,8 +88,6 @@ const ClickActionHandler = {
|
|||
const sourceLang = config.sourceLang || 'auto';
|
||||
const targetLang = config.targetLang || 'en';
|
||||
|
||||
// console.log(`[Translate] Provider: ${provider}, Word: "${word}"`);
|
||||
|
||||
try {
|
||||
switch (provider) {
|
||||
case 'GOOGLE':
|
||||
|
|
@ -125,12 +121,9 @@ const ClickActionHandler = {
|
|||
},
|
||||
|
||||
async translateGoogle(word, sourceLang, targetLang) {
|
||||
// Convert 3-letter codes to 2-letter codes for Google Translate API
|
||||
const sl = this.convertLangCode(sourceLang) || 'auto';
|
||||
const tl = this.convertLangCode(targetLang);
|
||||
|
||||
// Free Google Translate endpoint (unofficial, for demo purposes)
|
||||
// For production, use the official API with a key
|
||||
const url = `https://translate.googleapis.com/translate_a/single?client=gtx&sl=${sl}&tl=${tl}&dt=t&q=${encodeURIComponent(word)}`;
|
||||
|
||||
try {
|
||||
|
|
@ -166,9 +159,9 @@ const ClickActionHandler = {
|
|||
const targetLangNames = targetLangs.map((code) => this.resolveTargetLangName(code));
|
||||
const targetLangName = this.resolveTargetLangName(config.targetLang);
|
||||
|
||||
// Get provider-specific prompt or fallback to general llmPrompt
|
||||
// Get provider-specific prompt or fallback to general prompt
|
||||
const provider = config.provider || 'GOOGLE';
|
||||
const prompt = config.providerPrompts?.[provider] || config.llmPrompt || 'Define "{word}" briefly in {targetLang}.';
|
||||
const prompt = config.providerPrompts?.[provider] || 'Define "{word}" briefly in {targetLang}.';
|
||||
|
||||
return prompt
|
||||
.replace('{word}', word)
|
||||
|
|
|
|||
|
|
@ -40,13 +40,12 @@ export interface InteractiveSettings {
|
|||
provider: TranslationProvider;
|
||||
sourceLang: string;
|
||||
targetLang: string;
|
||||
targetLangs: string[]; // Multiple target languages for LLMs
|
||||
apiKey: string; // Deprecated: kept for backward compatibility
|
||||
providerApiKeys: Record<string, string>; // API keys per provider
|
||||
providerUrls: Record<string, string>; // Base URLs per provider
|
||||
providerModels: Record<string, string>; // Model names per provider
|
||||
providerPrompts: Record<string, string>; // Custom prompts per provider
|
||||
llmPrompt: string; // Deprecated: kept for backward compatibility
|
||||
targetLangs: string[];
|
||||
apiKey: string;
|
||||
providerApiKeys: Record<string, string>;
|
||||
providerUrls: Record<string, string>;
|
||||
providerModels: Record<string, string>;
|
||||
providerPrompts: Record<string, string>;
|
||||
webhookUrl: string;
|
||||
pauseOnTranslate: boolean;
|
||||
pauseOnCopy: boolean;
|
||||
|
|
@ -59,7 +58,7 @@ const STORAGE_KEY = 'stremio_interactive_subtitles_settings';
|
|||
const CACHE_KEY = 'stremio_interactive_subtitles_cache';
|
||||
|
||||
const DEFAULT_SETTINGS: InteractiveSettings = {
|
||||
uiMode: 'OVERLAY',
|
||||
uiMode: 'NATIVE',
|
||||
clickAction: 'TRANSLATE',
|
||||
provider: 'GOOGLE',
|
||||
sourceLang: 'auto',
|
||||
|
|
@ -70,7 +69,6 @@ const DEFAULT_SETTINGS: InteractiveSettings = {
|
|||
providerUrls: { ...DEFAULT_PROVIDER_URLS },
|
||||
providerModels: { ...DEFAULT_PROVIDER_MODELS },
|
||||
providerPrompts: { ...DEFAULT_PROVIDER_PROMPTS },
|
||||
llmPrompt: '"{word}" - give one or more translations in {targetLangs}.\n-Use plain text. \n -No additional text except translations. Format: \n[lang]: translation 1, translation2 ...',
|
||||
webhookUrl: '',
|
||||
pauseOnTranslate: true,
|
||||
pauseOnCopy: false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue