Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions backend/chainlit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@

# default_theme = "dark"

# Force a specific language for all users (e.g., "en-US", "he-IL", "fr-FR")
# If not set, the browser's language will be used
# language = "en-US"

# layout = "wide"

# default_sidebar_state = "open"
Expand Down Expand Up @@ -323,6 +327,7 @@ class UISettings(BaseModel):
description: str = ""
cot: Literal["hidden", "tool_call", "full"] = "full"
default_theme: Optional[Literal["light", "dark"]] = "dark"
language: Optional[str] = None
layout: Optional[Literal["default", "wide"]] = "default"
default_sidebar_state: Optional[Literal["open", "closed"]] = "open"
github: Optional[str] = None
Expand Down
18 changes: 13 additions & 5 deletions backend/chainlit/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,11 @@ async def project_translations(
):
"""Return project translations."""

# Load translation based on the provided language
translation = config.load_translation(language)
# Use configured language if set, otherwise use the language from query
effective_language = config.ui.language or language

# Load translation based on the effective language
translation = config.load_translation(effective_language)

return JSONResponse(
content={
Expand All @@ -806,13 +809,18 @@ async def project_settings(
):
"""Return project settings. This is called by the UI before the establishing the websocket connection."""

# Use configured language if set, otherwise use the language from query
effective_language = config.ui.language or language

# Load the markdown file based on the provided language
markdown = get_markdown_str(config.root, language)
markdown = get_markdown_str(config.root, effective_language)

chat_profiles = []
profiles: list[dict] = []
if config.code.set_chat_profiles:
chat_profiles = await config.code.set_chat_profiles(current_user, language)
chat_profiles = await config.code.set_chat_profiles(
current_user, effective_language
)
if chat_profiles:
for p in chat_profiles:
d = p.to_dict()
Expand All @@ -821,7 +829,7 @@ async def project_settings(

starters = []
if config.code.set_starters:
s = await config.code.set_starters(current_user, language)
s = await config.code.set_starters(current_user, effective_language)
if s:
starters = [it.to_dict() for it in s]

Expand Down
Loading