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
2 changes: 1 addition & 1 deletion .cursorrules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- Only include essential comments where the code is not self-explanatory. Avoid redundant or obvious comments.
- All comments must be in English and only included where the code is not self-explanatory—avoid redundant or obvious comments.
- You can read docs/.ai/SOP.server.zh-CN.md for server when the task starts.
- You can read docs/.ai/SOP.client.zh-CN.md for web when the task starts.
- Please check out docs/.ai/release.md for the release process.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ TZ=UTC

SUPER_ADMIN_USERNAME=admin
SUPER_ADMIN_PASSWORD=297df52fbc321ebf7198d497fe1c9206PlsChangeMe

APISERVER_I18N_PATH=./configs/i18n
17 changes: 17 additions & 0 deletions cmd/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"time"

"github.com/mcp-ecosystem/mcp-gateway/internal/i18n"

"github.com/mcp-ecosystem/mcp-gateway/pkg/logger"

"github.com/mcp-ecosystem/mcp-gateway/internal/apiserver/database"
Expand Down Expand Up @@ -230,6 +232,18 @@ func startServer(logger *zap.Logger, router *gin.Engine) {
}
}

// initI18n initializes the i18n translator
func initI18n(cfg *config.I18nConfig) {
translationsPath := cfg.Path
if translationsPath == "" {
translationsPath = "configs/i18n"
}

if err := i18n.InitTranslator(translationsPath); err != nil {
log.Printf("Warning: Failed to load translations: %v\n", err)
}
}

func run() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -249,6 +263,9 @@ func run() {
db := initDatabase(logger, &cfg.Database)
defer db.Close()

// Initialize i18n translator
initI18n(&cfg.I18n)

// Initialize super admin
if err := initSuperAdmin(ctx, db, cfg); err != nil {
logger.Fatal("Failed to initialize super admin", zap.Error(err))
Expand Down
4 changes: 4 additions & 0 deletions configs/apiserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ logger:
color: ${APISERVER_LOGGER_COLOR:true} # whether to use color in console output
stacktrace: ${APISERVER_LOGGER_STACKTRACE:true} # whether to include stacktrace in error logs

# i18n configuration
i18n:
path: "${APISERVER_I18N_PATH:./configs/i18n}" # path to i18n translation files

# Super admin configuration
super_admin:
username: "${SUPER_ADMIN_USERNAME:admin}"
Expand Down
Loading