Skip to content

A Simple and Universal Swarm Intelligence Engine, Predicting Anything. 简洁通用的群体智能引擎,预测万物

feat(i18n): replace remaining hardcoded Chinese in progress callbacks

ghostubborn592ee52f59c4
diff --git a/backend/app/services/oasis_profile_generator.py b/backend/app/services/oasis_profile_generator.py
index 0e473668..83f49cbb 100644
--- a/backend/app/services/oasis_profile_generator.py
+++ b/backend/app/services/oasis_profile_generator.py
@@ -20,7 +20,7 @@ from zep_cloud.client import Zep
from ..config import Config
from ..utils.logger import get_logger
-from ..utils.locale import get_language_instruction
+from ..utils.locale import get_language_instruction, t
from .zep_entity_reader import EntityNode, ZepEntityReader
logger = get_logger('mirofish.oasis_profile')
@@ -314,7 +314,7 @@ class OasisProfileGenerator:
logger.debug(f"跳过Zep检索:未设置graph_id")
return results
- comprehensive_query = f"关于{entity_name}的所有信息、活动、事件、关系和背景"
+ comprehensive_query = t('progress.zepSearchQuery', name=entity_name)
def search_edges():
"""搜索边(事实/关系)- 带重试机制"""
diff --git a/backend/app/services/simulation_config_generator.py b/backend/app/services/simulation_config_generator.py
index 3b57abc9..61db24d3 100644
--- a/backend/app/services/simulation_config_generator.py
+++ b/backend/app/services/simulation_config_generator.py
@@ -20,7 +20,7 @@ from openai import OpenAI
from ..config import Config
from ..utils.logger import get_logger
-from ..utils.locale import get_language_instruction
+from ..utils.locale import get_language_instruction, t
from .zep_entity_reader import EntityNode, ZepEntityReader
logger = get_logger('mirofish.simulation_config')
@@ -293,14 +293,14 @@ class SimulationConfigGenerator:
reasoning_parts = []
# ========== 步骤1: 生成时间配置 ==========
- report_progress(1, "生成时间配置...")
+ report_progress(1, t('progress.generatingTimeConfig'))
num_entities = len(entities)
time_config_result = self._generate_time_config(context, num_entities)
time_config = self._parse_time_config(time_config_result, num_entities)
reasoning_parts.append(f"时间配置: {time_config_result.get('reasoning', '成功')}")
# ========== 步骤2: 生成事件配置 ==========
- report_progress(2, "生成事件配置和热点话题...")
+ report_progress(2, t('progress.generatingEventConfig'))
event_config_result = self._generate_event_config(context, simulation_requirement, entities)
event_config = self._parse_event_config(event_config_result)
reasoning_parts.append(f"事件配置: {event_config_result.get('reasoning', '成功')}")
@@ -314,7 +314,7 @@ class SimulationConfigGenerator:
report_progress(
3 + batch_idx,
- f"生成Agent配置 ({start_idx + 1}-{end_idx}/{len(entities)})..."
+ t('progress.generatingAgentConfig', start=start_idx + 1, end=end_idx, total=len(entities))
)
batch_configs = self._generate_agent_configs_batch(
@@ -334,7 +334,7 @@ class SimulationConfigGenerator:
reasoning_parts.append(f"初始帖子分配: {assigned_count} 个帖子已分配发布者")
# ========== 最后一步: 生成平台配置 ==========
- report_progress(total_steps, "生成平台配置...")
+ report_progress(total_steps, t('progress.generatingPlatformConfig'))
twitter_config = None
reddit_config = None
diff --git a/backend/app/services/simulation_manager.py b/backend/app/services/simulation_manager.py
index c80f48c3..0d161a90 100644
--- a/backend/app/services/simulation_manager.py
+++ b/backend/app/services/simulation_manager.py
@@ -352,8 +352,8 @@ class SimulationManager:
# Reddit 已经在生成过程中实时保存了,这里再保存一次确保完整性
if progress_callback:
progress_callback(
- "generating_profiles", 95,
- "保存Profile文件...",
+ "generating_profiles", 95,
+ t('progress.savingProfiles'),
current=total_entities,
total=total_entities
)
@@ -375,8 +375,8 @@ class SimulationManager:
if progress_callback:
progress_callback(
- "generating_profiles", 100,
- f"完成,共 {len(profiles)} 个Profile",
+ "generating_profiles", 100,
+ t('progress.profilesComplete', count=len(profiles)),
current=len(profiles),
total=len(profiles)
)
@@ -384,8 +384,8 @@ class SimulationManager:
# ========== 阶段3: LLM智能生成模拟配置 ==========
if progress_callback:
progress_callback(
- "generating_config", 0,
- "正在分析模拟需求...",
+ "generating_config", 0,
+ t('progress.analyzingRequirements'),
current=0,
total=3
)
@@ -394,8 +394,8 @@ class SimulationManager:
if progress_callback:
progress_callback(
- "generating_config", 30,
- "正在调用LLM生成配置...",
+ "generating_config", 30,
+ t('progress.callingLLMConfig'),
current=1,
total=3
)
@@ -413,8 +413,8 @@ class SimulationManager:
if progress_callback:
progress_callback(
- "generating_config", 70,
- "正在保存配置文件...",
+ "generating_config", 70,
+ t('progress.savingConfigFiles'),
current=2,
total=3
)
@@ -429,8 +429,8 @@ class SimulationManager:
if progress_callback:
progress_callback(
- "generating_config", 100,
- "配置生成完成",
+ "generating_config", 100,
+ t('progress.configComplete'),
current=3,
total=3
)
diff --git a/locales/en.json b/locales/en.json
index f0e9d608..db5cc71e 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -394,7 +394,17 @@
"sectionDone": "Section {title} complete",
"assemblingReport": "Assembling full report...",
"reportComplete": "Report generation complete",
- "reportFailed": "Report generation failed: {error}"
+ "reportFailed": "Report generation failed: {error}",
+ "savingProfiles": "Saving profile files...",
+ "profilesComplete": "Done, {count} profiles generated",
+ "callingLLMConfig": "Calling LLM to generate config...",
+ "savingConfigFiles": "Saving config files...",
+ "configComplete": "Config generation complete",
+ "generatingTimeConfig": "Generating time config...",
+ "generatingEventConfig": "Generating event config and hot topics...",
+ "generatingAgentConfig": "Generating agent config ({start}-{end}/{total})...",
+ "generatingPlatformConfig": "Generating platform config...",
+ "zepSearchQuery": "All information, activities, events, relationships and background about {name}"
},
"log": {
"preparingGoBack": "Preparing to return to Step 2, closing simulation...",
diff --git a/locales/zh.json b/locales/zh.json
index c524a04d..7d8157a7 100644
--- a/locales/zh.json
+++ b/locales/zh.json
@@ -394,7 +394,17 @@
"sectionDone": "章节 {title} 已完成",
"assemblingReport": "正在组装完整报告...",
"reportComplete": "报告生成完成",
- "reportFailed": "报告生成失败: {error}"
+ "reportFailed": "报告生成失败: {error}",
+ "savingProfiles": "保存Profile文件...",
+ "profilesComplete": "完成,共 {count} 个Profile",
+ "callingLLMConfig": "正在调用LLM生成配置...",
+ "savingConfigFiles": "正在保存配置文件...",
+ "configComplete": "配置生成完成",
+ "generatingTimeConfig": "生成时间配置...",
+ "generatingEventConfig": "生成事件配置和热点话题...",
+ "generatingAgentConfig": "生成Agent配置 ({start}-{end}/{total})...",
+ "generatingPlatformConfig": "生成平台配置...",
+ "zepSearchQuery": "关于{name}的所有信息、活动、事件、关系和背景"
},
"log": {
"preparingGoBack": "准备返回 Step 2,正在关闭模拟...",