HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/kohya_ss/kohya_gui/localization_ext.py
import os
import gradio as gr
import kohya_gui.localization as localization


def file_path(fn):
    return f"file={os.path.abspath(fn)}?{os.path.getmtime(fn)}"


def js_html_str(language):
    head = f'<script type="text/javascript">{localization.load_language_js(language)}</script>\n'
    head += (
        f'<script type="text/javascript">{open("./assets/js/script.js", "r", encoding="utf-8").read()}</script>\n'
    )
    head += f'<script type="text/javascript">{open("./assets/js/localization.js", "r", encoding="utf-8").read()}</script>\n'
    return head


def add_javascript(language):
    if language is None:
        # print('no language')
        return
    jsStr = js_html_str(language)

    def template_response(*args, **kwargs):
        res = localization.GrRoutesTemplateResponse(*args, **kwargs)
        res.body = res.body.replace(b"</head>", f"{jsStr}</head>".encode("utf-8"))
        res.init_headers()
        return res

    gr.routes.templates.TemplateResponse = template_response


if not hasattr(localization, "GrRoutesTemplateResponse"):
    localization.GrRoutesTemplateResponse = gr.routes.templates.TemplateResponse