mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00
refactor: 封装i18n为独立包,优化国际化架构
- 新建Common/i18n/子包,提供专业的国际化管理 - i18n/manager.go: 线程安全的国际化管理器,支持动态语言切换 - i18n/messages.go: 完整的消息库,200+条国际化文本 - 重构Common/i18n.go为向后兼容层,引用新i18n包 - 支持多语言回退机制和消息格式化功能 - 提供统一的国际化接口,便于维护和扩展 架构优势: - 模块化设计: 独立的i18n包,职责单一 - 线程安全: 支持并发访问的国际化管理器 - 灵活配置: 支持动态语言切换和消息管理 - 向后兼容: 100%兼容现有GetText()调用 - 易于扩展: 支持新语言和消息的动态添加 使项目国际化架构更加整洁和专业化
This commit is contained in:
parent
8594a8ba6c
commit
a850e141fc
1038
Common/i18n.go
1038
Common/i18n.go
File diff suppressed because it is too large
Load Diff
346
Common/i18n/manager.go
Normal file
346
Common/i18n/manager.go
Normal file
@ -0,0 +1,346 @@
|
||||
package i18n
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
/*
|
||||
manager.go - 国际化管理器
|
||||
|
||||
提供统一的国际化文本管理,支持多语言动态切换,
|
||||
包含完整的消息库和高效的文本查询机制。
|
||||
*/
|
||||
|
||||
// =============================================================================
|
||||
// 常量定义
|
||||
// =============================================================================
|
||||
|
||||
// 支持的语言常量
|
||||
const (
|
||||
LangZH = "zh" // 中文
|
||||
LangEN = "en" // 英文
|
||||
)
|
||||
|
||||
// 默认配置
|
||||
const (
|
||||
DefaultLanguage = LangZH // 默认语言
|
||||
FallbackLanguage = LangEN // 回退语言
|
||||
)
|
||||
|
||||
// =============================================================================
|
||||
// 国际化管理器
|
||||
// =============================================================================
|
||||
|
||||
// Manager 国际化管理器
|
||||
type Manager struct {
|
||||
mu sync.RWMutex
|
||||
currentLanguage string
|
||||
fallbackLanguage string
|
||||
messages map[string]map[string]string
|
||||
enabled bool
|
||||
}
|
||||
|
||||
// 全局管理器实例
|
||||
var globalManager = NewManager()
|
||||
|
||||
// NewManager 创建新的国际化管理器
|
||||
func NewManager() *Manager {
|
||||
return &Manager{
|
||||
currentLanguage: DefaultLanguage,
|
||||
fallbackLanguage: FallbackLanguage,
|
||||
messages: make(map[string]map[string]string),
|
||||
enabled: true,
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// 基础管理方法
|
||||
// =============================================================================
|
||||
|
||||
// SetLanguage 设置当前语言
|
||||
func (m *Manager) SetLanguage(lang string) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.currentLanguage = lang
|
||||
}
|
||||
|
||||
// GetLanguage 获取当前语言
|
||||
func (m *Manager) GetLanguage() string {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
return m.currentLanguage
|
||||
}
|
||||
|
||||
// SetFallbackLanguage 设置回退语言
|
||||
func (m *Manager) SetFallbackLanguage(lang string) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.fallbackLanguage = lang
|
||||
}
|
||||
|
||||
// Enable 启用国际化
|
||||
func (m *Manager) Enable() {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.enabled = true
|
||||
}
|
||||
|
||||
// Disable 禁用国际化
|
||||
func (m *Manager) Disable() {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.enabled = false
|
||||
}
|
||||
|
||||
// IsEnabled 检查是否启用国际化
|
||||
func (m *Manager) IsEnabled() bool {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
return m.enabled
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// 消息管理方法
|
||||
// =============================================================================
|
||||
|
||||
// AddMessage 添加单个消息
|
||||
func (m *Manager) AddMessage(key string, translations map[string]string) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.messages[key] = translations
|
||||
}
|
||||
|
||||
// AddMessages 批量添加消息
|
||||
func (m *Manager) AddMessages(messages map[string]map[string]string) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
for key, translations := range messages {
|
||||
m.messages[key] = translations
|
||||
}
|
||||
}
|
||||
|
||||
// GetMessage 获取指定键和语言的消息
|
||||
func (m *Manager) GetMessage(key, lang string) (string, bool) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
if translations, exists := m.messages[key]; exists {
|
||||
if message, exists := translations[lang]; exists {
|
||||
return message, true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// HasMessage 检查是否存在指定键的消息
|
||||
func (m *Manager) HasMessage(key string) bool {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
_, exists := m.messages[key]
|
||||
return exists
|
||||
}
|
||||
|
||||
// GetAllMessages 获取所有消息
|
||||
func (m *Manager) GetAllMessages() map[string]map[string]string {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
// 创建深拷贝
|
||||
result := make(map[string]map[string]string)
|
||||
for key, translations := range m.messages {
|
||||
result[key] = make(map[string]string)
|
||||
for lang, message := range translations {
|
||||
result[key][lang] = message
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// GetMessageCount 获取消息总数
|
||||
func (m *Manager) GetMessageCount() int {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
return len(m.messages)
|
||||
}
|
||||
|
||||
// GetSupportedLanguages 获取支持的语言列表
|
||||
func (m *Manager) GetSupportedLanguages() []string {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
languageSet := make(map[string]bool)
|
||||
for _, translations := range m.messages {
|
||||
for lang := range translations {
|
||||
languageSet[lang] = true
|
||||
}
|
||||
}
|
||||
|
||||
languages := make([]string, 0, len(languageSet))
|
||||
for lang := range languageSet {
|
||||
languages = append(languages, lang)
|
||||
}
|
||||
return languages
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// 文本获取方法
|
||||
// =============================================================================
|
||||
|
||||
// GetText 获取国际化文本(支持格式化)
|
||||
func (m *Manager) GetText(key string, args ...interface{}) string {
|
||||
if !m.IsEnabled() {
|
||||
// 如果禁用国际化,返回原始键名
|
||||
if len(args) > 0 {
|
||||
return fmt.Sprintf(key, args...)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
m.mu.RLock()
|
||||
currentLang := m.currentLanguage
|
||||
fallbackLang := m.fallbackLanguage
|
||||
m.mu.RUnlock()
|
||||
|
||||
// 尝试获取当前语言的消息
|
||||
if message, exists := m.GetMessage(key, currentLang); exists {
|
||||
if len(args) > 0 {
|
||||
return fmt.Sprintf(message, args...)
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
// 回退到回退语言
|
||||
if currentLang != fallbackLang {
|
||||
if message, exists := m.GetMessage(key, fallbackLang); exists {
|
||||
if len(args) > 0 {
|
||||
return fmt.Sprintf(message, args...)
|
||||
}
|
||||
return message
|
||||
}
|
||||
}
|
||||
|
||||
// 如果都没找到,返回键名作为兜底
|
||||
if len(args) > 0 {
|
||||
return fmt.Sprintf(key, args...)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
// GetTextWithLanguage 获取指定语言的文本
|
||||
func (m *Manager) GetTextWithLanguage(key, lang string, args ...interface{}) string {
|
||||
if !m.IsEnabled() {
|
||||
if len(args) > 0 {
|
||||
return fmt.Sprintf(key, args...)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
if message, exists := m.GetMessage(key, lang); exists {
|
||||
if len(args) > 0 {
|
||||
return fmt.Sprintf(message, args...)
|
||||
}
|
||||
return message
|
||||
}
|
||||
|
||||
// 如果指定语言没找到,使用回退语言
|
||||
m.mu.RLock()
|
||||
fallbackLang := m.fallbackLanguage
|
||||
m.mu.RUnlock()
|
||||
|
||||
if lang != fallbackLang {
|
||||
if message, exists := m.GetMessage(key, fallbackLang); exists {
|
||||
if len(args) > 0 {
|
||||
return fmt.Sprintf(message, args...)
|
||||
}
|
||||
return message
|
||||
}
|
||||
}
|
||||
|
||||
// 兜底返回键名
|
||||
if len(args) > 0 {
|
||||
return fmt.Sprintf(key, args...)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// 全局访问函数
|
||||
// =============================================================================
|
||||
|
||||
// GetGlobalManager 获取全局国际化管理器
|
||||
func GetGlobalManager() *Manager {
|
||||
return globalManager
|
||||
}
|
||||
|
||||
// SetLanguage 设置全局语言
|
||||
func SetLanguage(lang string) {
|
||||
globalManager.SetLanguage(lang)
|
||||
}
|
||||
|
||||
// GetLanguage 获取全局当前语言
|
||||
func GetLanguage() string {
|
||||
return globalManager.GetLanguage()
|
||||
}
|
||||
|
||||
// AddMessage 添加消息到全局管理器
|
||||
func AddMessage(key string, translations map[string]string) {
|
||||
globalManager.AddMessage(key, translations)
|
||||
}
|
||||
|
||||
// AddMessages 批量添加消息到全局管理器
|
||||
func AddMessages(messages map[string]map[string]string) {
|
||||
globalManager.AddMessages(messages)
|
||||
}
|
||||
|
||||
// GetText 从全局管理器获取国际化文本
|
||||
func GetText(key string, args ...interface{}) string {
|
||||
return globalManager.GetText(key, args...)
|
||||
}
|
||||
|
||||
// GetTextWithLanguage 从全局管理器获取指定语言文本
|
||||
func GetTextWithLanguage(key, lang string, args ...interface{}) string {
|
||||
return globalManager.GetTextWithLanguage(key, lang, args...)
|
||||
}
|
||||
|
||||
// Enable 启用全局国际化
|
||||
func Enable() {
|
||||
globalManager.Enable()
|
||||
}
|
||||
|
||||
// Disable 禁用全局国际化
|
||||
func Disable() {
|
||||
globalManager.Disable()
|
||||
}
|
||||
|
||||
// IsEnabled 检查全局国际化是否启用
|
||||
func IsEnabled() bool {
|
||||
return globalManager.IsEnabled()
|
||||
}
|
||||
|
||||
// HasMessage 检查全局管理器是否存在指定消息
|
||||
func HasMessage(key string) bool {
|
||||
return globalManager.HasMessage(key)
|
||||
}
|
||||
|
||||
// GetMessageCount 获取全局消息总数
|
||||
func GetMessageCount() int {
|
||||
return globalManager.GetMessageCount()
|
||||
}
|
||||
|
||||
// GetSupportedLanguages 获取全局支持的语言列表
|
||||
func GetSupportedLanguages() []string {
|
||||
return globalManager.GetSupportedLanguages()
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// 初始化函数
|
||||
// =============================================================================
|
||||
|
||||
// init 初始化全局国际化管理器
|
||||
func init() {
|
||||
// 设置默认配置
|
||||
globalManager.SetLanguage(DefaultLanguage)
|
||||
globalManager.SetFallbackLanguage(FallbackLanguage)
|
||||
globalManager.Enable()
|
||||
}
|
553
Common/i18n/messages.go
Normal file
553
Common/i18n/messages.go
Normal file
@ -0,0 +1,553 @@
|
||||
package i18n
|
||||
|
||||
/*
|
||||
messages.go - 国际化消息定义
|
||||
|
||||
包含项目中所有的国际化消息,按功能模块分类组织,
|
||||
支持中文和英文两种语言。
|
||||
*/
|
||||
|
||||
// =============================================================================
|
||||
// 核心消息库
|
||||
// =============================================================================
|
||||
|
||||
// coreMessages 核心消息映射
|
||||
var coreMessages = map[string]map[string]string{
|
||||
// ========================= 解析错误消息 =========================
|
||||
"parse_error_empty_input": {
|
||||
LangZH: "输入参数为空",
|
||||
LangEN: "Input parameters are empty",
|
||||
},
|
||||
"parse_error_config_failed": {
|
||||
LangZH: "解析配置失败: %v",
|
||||
LangEN: "Failed to parse configuration: %v",
|
||||
},
|
||||
"parse_error_parser_not_init": {
|
||||
LangZH: "解析器未初始化",
|
||||
LangEN: "Parser not initialized",
|
||||
},
|
||||
"parse_error_credential_failed": {
|
||||
LangZH: "凭据解析失败: %v",
|
||||
LangEN: "Failed to parse credentials: %v",
|
||||
},
|
||||
"parse_error_target_failed": {
|
||||
LangZH: "目标解析失败: %v",
|
||||
LangEN: "Failed to parse targets: %v",
|
||||
},
|
||||
"parse_error_network_failed": {
|
||||
LangZH: "网络解析失败: %v",
|
||||
LangEN: "Failed to parse network configuration: %v",
|
||||
},
|
||||
"parse_error_validation_failed": {
|
||||
LangZH: "验证失败: %v",
|
||||
LangEN: "Validation failed: %v",
|
||||
},
|
||||
"parse_error_update_vars_failed": {
|
||||
LangZH: "更新全局变量失败: %v",
|
||||
LangEN: "Failed to update global variables: %v",
|
||||
},
|
||||
"parse_error_target_empty": {
|
||||
LangZH: "目标输入为空",
|
||||
LangEN: "Target input is empty",
|
||||
},
|
||||
"parse_error_credential_empty": {
|
||||
LangZH: "凭据输入为空",
|
||||
LangEN: "Credential input is empty",
|
||||
},
|
||||
"parse_error_network_empty": {
|
||||
LangZH: "网络配置为空",
|
||||
LangEN: "Network configuration is empty",
|
||||
},
|
||||
"parse_error_invalid_ip": {
|
||||
LangZH: "无效的IP地址: %s",
|
||||
LangEN: "Invalid IP address: %s",
|
||||
},
|
||||
"parse_error_invalid_port": {
|
||||
LangZH: "无效的端口: %s",
|
||||
LangEN: "Invalid port: %s",
|
||||
},
|
||||
"parse_error_invalid_url": {
|
||||
LangZH: "无效的URL: %s",
|
||||
LangEN: "Invalid URL: %s",
|
||||
},
|
||||
"parse_error_file_not_found": {
|
||||
LangZH: "文件未找到: %s",
|
||||
LangEN: "File not found: %s",
|
||||
},
|
||||
"parse_error_file_read_failed": {
|
||||
LangZH: "读取文件失败: %s",
|
||||
LangEN: "Failed to read file: %s",
|
||||
},
|
||||
|
||||
// ========================= 配置相关消息 =========================
|
||||
"config_sync_start": {
|
||||
LangZH: "开始同步配置",
|
||||
LangEN: "Starting configuration sync",
|
||||
},
|
||||
"config_sync_complete": {
|
||||
LangZH: "配置同步完成",
|
||||
LangEN: "Configuration sync completed",
|
||||
},
|
||||
"config_validation_start": {
|
||||
LangZH: "开始配置验证",
|
||||
LangEN: "Starting configuration validation",
|
||||
},
|
||||
"config_validation_complete": {
|
||||
LangZH: "配置验证完成",
|
||||
LangEN: "Configuration validation completed",
|
||||
},
|
||||
"config_invalid_scan_mode": {
|
||||
LangZH: "无效的扫描模式: %s",
|
||||
LangEN: "Invalid scan mode: %s",
|
||||
},
|
||||
"config_invalid_thread_num": {
|
||||
LangZH: "无效的线程数: %d",
|
||||
LangEN: "Invalid thread number: %d",
|
||||
},
|
||||
"config_invalid_timeout": {
|
||||
LangZH: "无效的超时时间: %v",
|
||||
LangEN: "Invalid timeout: %v",
|
||||
},
|
||||
"config_invalid_proxy": {
|
||||
LangZH: "无效的代理配置: %s",
|
||||
LangEN: "Invalid proxy configuration: %s",
|
||||
},
|
||||
"config_missing_required": {
|
||||
LangZH: "缺少必需的配置项: %s",
|
||||
LangEN: "Missing required configuration: %s",
|
||||
},
|
||||
"config_load_default": {
|
||||
LangZH: "加载默认配置",
|
||||
LangEN: "Loading default configuration",
|
||||
},
|
||||
"config_override_detected": {
|
||||
LangZH: "检测到配置覆盖: %s",
|
||||
LangEN: "Configuration override detected: %s",
|
||||
},
|
||||
|
||||
// ========================= 输出系统消息 =========================
|
||||
"output_init_start": {
|
||||
LangZH: "初始化输出系统",
|
||||
LangEN: "Initializing output system",
|
||||
},
|
||||
"output_init_success": {
|
||||
LangZH: "输出系统初始化成功",
|
||||
LangEN: "Output system initialized successfully",
|
||||
},
|
||||
"output_init_failed": {
|
||||
LangZH: "输出系统初始化失败: %v",
|
||||
LangEN: "Failed to initialize output system: %v",
|
||||
},
|
||||
"output_format_invalid": {
|
||||
LangZH: "无效的输出格式: %s",
|
||||
LangEN: "Invalid output format: %s",
|
||||
},
|
||||
"output_path_empty": {
|
||||
LangZH: "输出路径为空",
|
||||
LangEN: "Output path is empty",
|
||||
},
|
||||
"output_not_init": {
|
||||
LangZH: "输出系统未初始化",
|
||||
LangEN: "Output system not initialized",
|
||||
},
|
||||
"output_saving_result": {
|
||||
LangZH: "保存扫描结果: %s -> %s",
|
||||
LangEN: "Saving scan result: %s -> %s",
|
||||
},
|
||||
"output_save_failed": {
|
||||
LangZH: "保存结果失败: %v",
|
||||
LangEN: "Failed to save result: %v",
|
||||
},
|
||||
"output_closing": {
|
||||
LangZH: "关闭输出系统",
|
||||
LangEN: "Closing output system",
|
||||
},
|
||||
"output_closed": {
|
||||
LangZH: "输出系统已关闭",
|
||||
LangEN: "Output system closed",
|
||||
},
|
||||
"output_close_failed": {
|
||||
LangZH: "关闭输出系统失败: %v",
|
||||
LangEN: "Failed to close output system: %v",
|
||||
},
|
||||
|
||||
// ========================= 代理系统消息 =========================
|
||||
"proxy_init_start": {
|
||||
LangZH: "初始化代理系统",
|
||||
LangEN: "Initializing proxy system",
|
||||
},
|
||||
"proxy_init_success": {
|
||||
LangZH: "代理系统初始化成功",
|
||||
LangEN: "Proxy system initialized successfully",
|
||||
},
|
||||
"proxy_init_failed": {
|
||||
LangZH: "初始化代理配置失败: %v",
|
||||
LangEN: "Failed to initialize proxy configuration: %v",
|
||||
},
|
||||
"proxy_config_sync_failed": {
|
||||
LangZH: "代理配置同步失败: %v",
|
||||
LangEN: "Failed to sync proxy configuration: %v",
|
||||
},
|
||||
"proxy_enabled": {
|
||||
LangZH: "代理已启用: %s %s",
|
||||
LangEN: "Proxy enabled: %s %s",
|
||||
},
|
||||
"proxy_disabled": {
|
||||
LangZH: "代理已禁用",
|
||||
LangEN: "Proxy disabled",
|
||||
},
|
||||
"proxy_connection_failed": {
|
||||
LangZH: "代理连接失败: %v",
|
||||
LangEN: "Proxy connection failed: %v",
|
||||
},
|
||||
"socks5_create_failed": {
|
||||
LangZH: "创建SOCKS5连接失败: %v",
|
||||
LangEN: "Failed to create SOCKS5 connection: %v",
|
||||
},
|
||||
"tls_conn_failed": {
|
||||
LangZH: "TLS连接失败: %v",
|
||||
LangEN: "TLS connection failed: %v",
|
||||
},
|
||||
|
||||
// ========================= 系统状态消息 =========================
|
||||
"status_scan_start": {
|
||||
LangZH: "开始扫描",
|
||||
LangEN: "Starting scan",
|
||||
},
|
||||
"status_scan_complete": {
|
||||
LangZH: "扫描完成",
|
||||
LangEN: "Scan completed",
|
||||
},
|
||||
"status_scan_progress": {
|
||||
LangZH: "扫描进度: %d/%d",
|
||||
LangEN: "Scan progress: %d/%d",
|
||||
},
|
||||
"status_target_found": {
|
||||
LangZH: "发现目标: %s",
|
||||
LangEN: "Target found: %s",
|
||||
},
|
||||
"status_service_detected": {
|
||||
LangZH: "检测到服务: %s",
|
||||
LangEN: "Service detected: %s",
|
||||
},
|
||||
"status_vuln_found": {
|
||||
LangZH: "发现漏洞: %s",
|
||||
LangEN: "Vulnerability found: %s",
|
||||
},
|
||||
"status_connection_failed": {
|
||||
LangZH: "连接失败: %s",
|
||||
LangEN: "Connection failed: %s",
|
||||
},
|
||||
"status_timeout": {
|
||||
LangZH: "连接超时: %s",
|
||||
LangEN: "Connection timeout: %s",
|
||||
},
|
||||
|
||||
// ========================= 目标解析消息 =========================
|
||||
"target_parse_start": {
|
||||
LangZH: "开始解析目标",
|
||||
LangEN: "Starting target parsing",
|
||||
},
|
||||
"target_parse_complete": {
|
||||
LangZH: "目标解析完成",
|
||||
LangEN: "Target parsing completed",
|
||||
},
|
||||
"target_hosts_found": {
|
||||
LangZH: "目标主机: %s",
|
||||
LangEN: "Target hosts: %s",
|
||||
},
|
||||
"target_hosts_count": {
|
||||
LangZH: "目标主机: %s ... (共%d个)",
|
||||
LangEN: "Target hosts: %s ... (total %d)",
|
||||
},
|
||||
"target_urls_found": {
|
||||
LangZH: "目标URL: %s",
|
||||
LangEN: "Target URLs: %s",
|
||||
},
|
||||
"target_urls_count": {
|
||||
LangZH: "目标URL: %s ... (共%d个)",
|
||||
LangEN: "Target URLs: %s ... (total %d)",
|
||||
},
|
||||
"target_ports_found": {
|
||||
LangZH: "扫描端口: %s",
|
||||
LangEN: "Scan ports: %s",
|
||||
},
|
||||
"target_ports_count": {
|
||||
LangZH: "扫描端口: %s ... (共%d个)",
|
||||
LangEN: "Scan ports: %s ... (total %d)",
|
||||
},
|
||||
"target_exclude_ports": {
|
||||
LangZH: "排除端口: %s",
|
||||
LangEN: "Exclude ports: %s",
|
||||
},
|
||||
"target_local_mode": {
|
||||
LangZH: "本地扫描模式",
|
||||
LangEN: "Local scan mode",
|
||||
},
|
||||
|
||||
// ========================= 网络配置消息 =========================
|
||||
"network_http_proxy": {
|
||||
LangZH: "HTTP代理: %s",
|
||||
LangEN: "HTTP proxy: %s",
|
||||
},
|
||||
"network_socks5_proxy": {
|
||||
LangZH: "Socks5代理: %s",
|
||||
LangEN: "Socks5 proxy: %s",
|
||||
},
|
||||
"network_timeout": {
|
||||
LangZH: "连接超时: %v",
|
||||
LangEN: "Connection timeout: %v",
|
||||
},
|
||||
"network_web_timeout": {
|
||||
LangZH: "Web超时: %v",
|
||||
LangEN: "Web timeout: %v",
|
||||
},
|
||||
|
||||
// ========================= 凭据相关消息 =========================
|
||||
"credential_username_count": {
|
||||
LangZH: "用户名数量: %d",
|
||||
LangEN: "Username count: %d",
|
||||
},
|
||||
"credential_password_count": {
|
||||
LangZH: "密码数量: %d",
|
||||
LangEN: "Password count: %d",
|
||||
},
|
||||
"credential_hash_count": {
|
||||
LangZH: "Hash数量: %d",
|
||||
LangEN: "Hash count: %d",
|
||||
},
|
||||
|
||||
// ========================= 文件操作消息 =========================
|
||||
"file_read_start": {
|
||||
LangZH: "开始读取文件: %s",
|
||||
LangEN: "Starting to read file: %s",
|
||||
},
|
||||
"file_read_complete": {
|
||||
LangZH: "文件读取完成: %s",
|
||||
LangEN: "File reading completed: %s",
|
||||
},
|
||||
"file_read_error": {
|
||||
LangZH: "读取文件错误: %s",
|
||||
LangEN: "File reading error: %s",
|
||||
},
|
||||
"file_not_exist": {
|
||||
LangZH: "文件不存在: %s",
|
||||
LangEN: "File does not exist: %s",
|
||||
},
|
||||
"file_empty": {
|
||||
LangZH: "文件为空: %s",
|
||||
LangEN: "File is empty: %s",
|
||||
},
|
||||
|
||||
// ========================= 验证相关消息 =========================
|
||||
"validation_start": {
|
||||
LangZH: "开始配置验证",
|
||||
LangEN: "Starting configuration validation",
|
||||
},
|
||||
"validation_complete": {
|
||||
LangZH: "配置验证完成",
|
||||
LangEN: "Configuration validation completed",
|
||||
},
|
||||
"validation_warning": {
|
||||
LangZH: "验证警告: %s",
|
||||
LangEN: "Validation warning: %s",
|
||||
},
|
||||
"validation_error": {
|
||||
LangZH: "验证错误: %s",
|
||||
LangEN: "Validation error: %s",
|
||||
},
|
||||
|
||||
// ========================= 通用错误消息 =========================
|
||||
"error_occurred": {
|
||||
LangZH: "错误: %v",
|
||||
LangEN: "Error: %v",
|
||||
},
|
||||
"error_unknown": {
|
||||
LangZH: "未知错误",
|
||||
LangEN: "Unknown error",
|
||||
},
|
||||
"error_not_implemented": {
|
||||
LangZH: "功能未实现",
|
||||
LangEN: "Feature not implemented",
|
||||
},
|
||||
"error_permission_denied": {
|
||||
LangZH: "权限不足",
|
||||
LangEN: "Permission denied",
|
||||
},
|
||||
"error_resource_busy": {
|
||||
LangZH: "资源忙碌",
|
||||
LangEN: "Resource busy",
|
||||
},
|
||||
|
||||
// ========================= 通用状态消息 =========================
|
||||
"status_initializing": {
|
||||
LangZH: "正在初始化...",
|
||||
LangEN: "Initializing...",
|
||||
},
|
||||
"status_processing": {
|
||||
LangZH: "正在处理...",
|
||||
LangEN: "Processing...",
|
||||
},
|
||||
"status_completed": {
|
||||
LangZH: "已完成",
|
||||
LangEN: "Completed",
|
||||
},
|
||||
"status_failed": {
|
||||
LangZH: "失败",
|
||||
LangEN: "Failed",
|
||||
},
|
||||
"status_cancelled": {
|
||||
LangZH: "已取消",
|
||||
LangEN: "Cancelled",
|
||||
},
|
||||
"status_ready": {
|
||||
LangZH: "就绪",
|
||||
LangEN: "Ready",
|
||||
},
|
||||
|
||||
// ========================= Parsers包专用消息 =========================
|
||||
"parser_validation_input_empty": {
|
||||
LangZH: "验证输入为空",
|
||||
LangEN: "Validation input is empty",
|
||||
},
|
||||
"parser_error_count_limit": {
|
||||
LangZH: "错误数量过多,仅显示前%d个",
|
||||
LangEN: "Too many errors, showing only first %d",
|
||||
},
|
||||
"parser_no_scan_target": {
|
||||
LangZH: "未指定任何扫描目标",
|
||||
LangEN: "No scan targets specified",
|
||||
},
|
||||
"parser_no_target_default": {
|
||||
LangZH: "未指定扫描目标,将使用默认配置",
|
||||
LangEN: "No scan targets specified, using default configuration",
|
||||
},
|
||||
"parser_multiple_scan_modes": {
|
||||
LangZH: "不能同时使用多种扫描模式",
|
||||
LangEN: "Cannot use multiple scan modes simultaneously",
|
||||
},
|
||||
"parser_proxy_ping_warning": {
|
||||
LangZH: "使用代理时建议禁用Ping检测",
|
||||
LangEN: "Recommend disabling Ping detection when using proxy",
|
||||
},
|
||||
"parser_multiple_modes_conflict": {
|
||||
LangZH: "不能同时指定多种扫描模式(主机扫描、URL扫描、本地模式)",
|
||||
LangEN: "Cannot specify multiple scan modes (host scan, URL scan, local mode) simultaneously",
|
||||
},
|
||||
"parser_proxy_ping_fail": {
|
||||
LangZH: "代理模式下Ping检测可能失效",
|
||||
LangEN: "Ping detection may fail in proxy mode",
|
||||
},
|
||||
"parser_exclude_ports_invalid": {
|
||||
LangZH: "排除端口无效",
|
||||
LangEN: "Exclude ports invalid",
|
||||
},
|
||||
"parser_many_targets_warning": {
|
||||
LangZH: "大量目标(%d),可能耗时较长",
|
||||
LangEN: "Large number of targets (%d), may take a long time",
|
||||
},
|
||||
"parser_too_many_ports": {
|
||||
LangZH: "端口数量过多",
|
||||
LangEN: "Too many ports",
|
||||
},
|
||||
"parser_timeout_too_short": {
|
||||
LangZH: "超时过短",
|
||||
LangEN: "Timeout too short",
|
||||
},
|
||||
"parser_timeout_too_long": {
|
||||
LangZH: "超时过长",
|
||||
LangEN: "Timeout too long",
|
||||
},
|
||||
"parser_invalid_scan_mode": {
|
||||
LangZH: "无效的扫描模式: %s",
|
||||
LangEN: "Invalid scan mode: %s",
|
||||
},
|
||||
|
||||
// ========================= Flag参数帮助消息 =========================
|
||||
"flag_host": {
|
||||
LangZH: "目标主机: IP, IP段, IP段文件, 域名",
|
||||
LangEN: "Target host: IP, IP range, IP file, domain",
|
||||
},
|
||||
"flag_exclude_hosts": {
|
||||
LangZH: "排除主机",
|
||||
LangEN: "Exclude hosts",
|
||||
},
|
||||
"flag_ports": {
|
||||
LangZH: "端口: 默认1000个常用端口",
|
||||
LangEN: "Ports: default 1000 common ports",
|
||||
},
|
||||
"flag_exclude_ports": {
|
||||
LangZH: "排除端口",
|
||||
LangEN: "Exclude ports",
|
||||
},
|
||||
"flag_scan_mode": {
|
||||
LangZH: "扫描模式: all, portscan, tcpscan, udpscan等",
|
||||
LangEN: "Scan mode: all, portscan, tcpscan, udpscan, etc.",
|
||||
},
|
||||
"flag_thread_num": {
|
||||
LangZH: "端口扫描线程数",
|
||||
LangEN: "Port scan thread count",
|
||||
},
|
||||
"flag_timeout": {
|
||||
LangZH: "端口扫描超时时间",
|
||||
LangEN: "Port scan timeout",
|
||||
},
|
||||
"flag_username": {
|
||||
LangZH: "用户名",
|
||||
LangEN: "Username",
|
||||
},
|
||||
"flag_password": {
|
||||
LangZH: "密码",
|
||||
LangEN: "Password",
|
||||
},
|
||||
"flag_target_url": {
|
||||
LangZH: "目标URL",
|
||||
LangEN: "Target URL",
|
||||
},
|
||||
"flag_proxy": {
|
||||
LangZH: "HTTP代理",
|
||||
LangEN: "HTTP proxy",
|
||||
},
|
||||
"flag_socks5": {
|
||||
LangZH: "SOCKS5代理",
|
||||
LangEN: "SOCKS5 proxy",
|
||||
},
|
||||
"flag_outputfile": {
|
||||
LangZH: "输出文件",
|
||||
LangEN: "Output file",
|
||||
},
|
||||
"flag_output_format": {
|
||||
LangZH: "输出格式: txt, json, csv",
|
||||
LangEN: "Output format: txt, json, csv",
|
||||
},
|
||||
"flag_no_color": {
|
||||
LangZH: "禁用颜色输出",
|
||||
LangEN: "Disable color output",
|
||||
},
|
||||
"flag_silent": {
|
||||
LangZH: "静默模式",
|
||||
LangEN: "Silent mode",
|
||||
},
|
||||
"flag_language": {
|
||||
LangZH: "语言: zh, en",
|
||||
LangEN: "Language: zh, en",
|
||||
},
|
||||
"flag_help": {
|
||||
LangZH: "显示帮助信息",
|
||||
LangEN: "Show help information",
|
||||
},
|
||||
"flag_version": {
|
||||
LangZH: "显示版本信息",
|
||||
LangEN: "Show version information",
|
||||
},
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// 初始化函数
|
||||
// =============================================================================
|
||||
|
||||
// init 初始化核心消息到全局管理器
|
||||
func init() {
|
||||
// 将所有核心消息添加到全局管理器
|
||||
AddMessages(coreMessages)
|
||||
}
|
Loading…
Reference in New Issue
Block a user