refactor: support i18n

This commit is contained in:
mlogclub
2026-05-25 12:06:15 +08:00
parent 309ac1fe9e
commit 988f55c80d
179 changed files with 10968 additions and 3763 deletions
+7 -2
View File
@@ -9,6 +9,7 @@ import (
"cs-agent/internal/pkg/config"
"cs-agent/internal/pkg/enums"
"cs-agent/internal/pkg/errorsx"
"cs-agent/internal/pkg/i18nx"
"cs-agent/internal/pkg/toolx"
)
@@ -33,6 +34,10 @@ type MCPToolCatalogItem struct {
}
func (s *toolCatalogService) ListMCPTools(ctx context.Context) ([]MCPToolCatalogItem, error) {
return s.ListMCPToolsWithLocale(ctx, i18nx.LocaleZhCN)
}
func (s *toolCatalogService) ListMCPToolsWithLocale(ctx context.Context, locale string) ([]MCPToolCatalogItem, error) {
cfg := config.Current()
ret := make([]MCPToolCatalogItem, 0, 3)
for _, spec := range toolx.ListAgentDirectToolSpecs() {
@@ -45,8 +50,8 @@ func (s *toolCatalogService) ListMCPTools(ctx context.Context) ([]MCPToolCatalog
ToolName: spec.Name,
SourceType: spec.SourceType,
AutoInjected: spec.AutoInjected,
Title: spec.Title,
Description: spec.Description,
Title: toolx.GetRegisteredToolTitleLocale(spec.Code, locale),
Description: toolx.GetRegisteredToolDescriptionLocale(spec.Code, locale),
})
}
if !cfg.MCP.Enabled {