File size: 1,639 Bytes
80fda88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import json
from uuid import uuid4

def get_system_locale():
    """Get system locale with fallback"""
    return "zh-CN"

def load_locales(i18n_dir):
    """Minimal locale loading"""
    try:
        zh_file = os.path.join(i18n_dir, "zh.json")
        if os.path.exists(zh_file):
            with open(zh_file, 'r', encoding='utf-8') as f:
                zh_data = json.load(f)
            return {"zh-CN": zh_data}
    except Exception:
        pass
    
    # Fallback minimal translations
    return {
        "zh-CN": {
            "Language": "中文",
            "Translation": {
                "Basic Settings": "基础设置",
                "Video Script Settings": "视频文案设置",
                "Generate Video": "生成视频"
            }
        }
    }

def get_uuid():
    """Generate UUID"""
    return str(uuid4())

def to_json(obj):
    """Convert object to JSON string"""
    try:
        return json.dumps(obj, ensure_ascii=False, indent=2)
    except Exception:
        return str(obj)

def storage_dir(subdir="", create=False):
    """Get storage directory"""
    root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
    storage_path = os.path.join(root_dir, "storage")
    if subdir:
        storage_path = os.path.join(storage_path, subdir)
    if create and not os.path.exists(storage_path):
        os.makedirs(storage_path, exist_ok=True)
    return storage_path

def task_dir(task_id=""):
    """Get task directory"""
    if task_id:
        return os.path.join(storage_dir("tasks", create=True), task_id)
    return storage_dir("tasks", create=True)