feat(i18n): Enhance internationalization support and error handling messages

- Added i18n keys for various error and info messages related to task management, user handling, and storage operations.
- Updated error messages in the watch and task handling commands to use i18n for better localization.
- Refactored error handling in the database initialization and user synchronization processes to provide clearer messages.
- Improved logging messages for better clarity and consistency across the application.
- Added comprehensive documentation for AI collaboration and project structure in the repository.
This commit is contained in:
krau
2025-12-19 16:01:36 +08:00
parent bc892d9370
commit 9ed2c425be
21 changed files with 564 additions and 142 deletions

View File

@@ -36,7 +36,7 @@ func Init(ctx context.Context) {
}
logger.Debug("Database connected")
if err := db.AutoMigrate(&User{}, &Dir{}, &Rule{}, &WatchChat{}); err != nil {
logger.Fatal("迁移数据库失败, 如果您从旧版本升级, 建议手动删除数据库文件后重试: ", err)
logger.Fatal("Database migration failed; if upgrading from an old version, try deleting the database file and retrying", "error", err)
}
if err := syncUsers(ctx); err != nil {
logger.Fatal("Failed to sync users:", err)
@@ -67,7 +67,7 @@ func syncUsers(ctx context.Context) error {
if err := CreateUser(ctx, cfgID); err != nil {
return fmt.Errorf("failed to create user %d: %w", cfgID, err)
}
logger.Infof("创建用户: %d", cfgID)
logger.Infof("Created user from config: %d", cfgID)
}
}
@@ -76,7 +76,7 @@ func syncUsers(ctx context.Context) error {
if err := DeleteUser(ctx, &dbUser); err != nil {
return fmt.Errorf("failed to delete user %d: %w", dbID, err)
}
logger.Infof("删除用户: %d", dbID)
logger.Infof("Deleted user not present in config: %d", dbID)
}
}