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

@@ -2,7 +2,6 @@ package config
import (
"context"
"errors"
"fmt"
"net"
"net/http"
@@ -11,8 +10,6 @@ import (
"time"
"github.com/duke-git/lancet/v2/slice"
"github.com/krau/SaveAny-Bot/common/i18n"
"github.com/krau/SaveAny-Bot/common/i18n/i18nk"
"github.com/krau/SaveAny-Bot/config/storage"
"github.com/spf13/viper"
"golang.org/x/net/proxy"
@@ -141,9 +138,7 @@ func Init(ctx context.Context, configFile ...string) error {
storageNames := make(map[string]struct{})
for _, storage := range cfg.Storages {
if _, ok := storageNames[storage.GetName()]; ok {
return errors.New(i18n.TWithoutInit(cfg.Lang, i18nk.ConfigErrDuplicateStorageName, map[string]any{
"Name": storage.GetName(),
}))
return fmt.Errorf("duplicate storage name: %s", storage.GetName())
}
storageNames[storage.GetName()] = struct{}{}
}