From d9c34c4524c37c1b8f6e5436ca8db9ae95f704ff Mon Sep 17 00:00:00 2001 From: Hoofei Date: Sun, 6 Apr 2025 12:09:30 +0800 Subject: [PATCH 01/14] Update Simplified Chinese --- .../public/locales/zh-Hans/common.json | 94 ++++++++++++++++++- .../public/locales/zh-Hans/settings.json | 40 ++++---- 2 files changed, 113 insertions(+), 21 deletions(-) diff --git a/apps/dokploy/public/locales/zh-Hans/common.json b/apps/dokploy/public/locales/zh-Hans/common.json index 0967ef42..67797618 100644 --- a/apps/dokploy/public/locales/zh-Hans/common.json +++ b/apps/dokploy/public/locales/zh-Hans/common.json @@ -1 +1,93 @@ -{} +{ + "dashboard.title": "仪表盘", + "dashboard.overview": "概览", + "dashboard.projects": "项目", + "dashboard.servers": "服务器", + "dashboard.docker": "Docker", + "dashboard.monitoring": "监控", + "dashboard.settings": "设置", + "dashboard.logout": "退出登录", + "dashboard.profile": "个人资料", + "dashboard.terminal": "终端", + "dashboard.containers": "容器", + "dashboard.images": "镜像", + "dashboard.volumes": "卷", + "dashboard.networks": "网络", + + "button.create": "创建", + "button.edit": "编辑", + "button.delete": "删除", + "button.cancel": "取消", + "button.save": "保存", + "button.confirm": "确认", + "button.back": "返回", + "button.next": "下一步", + "button.finish": "完成", + + "status.running": "运行中", + "status.stopped": "已停止", + "status.error": "错误", + "status.pending": "等待中", + "status.success": "成功", + "status.failed": "失败", + + "form.required": "必填", + "form.invalid": "无效", + "form.submit": "提交", + "form.reset": "重置", + + "notification.success": "操作成功", + "notification.error": "操作失败", + "notification.warning": "警告", + "notification.info": "信息", + + "time.now": "刚刚", + "time.minutes": "分钟前", + "time.hours": "小时前", + "time.days": "天前", + + "filter.all": "全部", + "filter.active": "活跃", + "filter.inactive": "不活跃", + + "sort.asc": "升序", + "sort.desc": "降序", + + "search.placeholder": "搜索...", + "search.noResults": "无结果", + + "pagination.prev": "上一页", + "pagination.next": "下一页", + "pagination.of": "共 {0} 页", + + "error.notFound": "未找到", + "error.serverError": "服务器错误", + "error.unauthorized": "未授权", + "error.forbidden": "禁止访问", + + "loading": "加载中...", + "empty": "暂无数据", + "more": "更多", + "less": "收起", + + "project.create": "创建项目", + "project.edit": "编辑项目", + "project.delete": "删除项目", + "project.name": "项目名称", + "project.description": "项目描述", + + "service.create": "创建服务", + "service.edit": "编辑服务", + "service.delete": "删除服务", + "service.name": "服务名称", + "service.type": "服务类型", + + "domain.add": "添加域名", + "domain.remove": "移除域名", + + "environment.variables": "环境变量", + "environment.add": "添加环境变量", + "environment.edit": "编辑环境变量", + "environment.name": "变量名", + "environment.value": "变量值" +} diff --git a/apps/dokploy/public/locales/zh-Hans/settings.json b/apps/dokploy/public/locales/zh-Hans/settings.json index c74fb21f..f7e8a38a 100644 --- a/apps/dokploy/public/locales/zh-Hans/settings.json +++ b/apps/dokploy/public/locales/zh-Hans/settings.json @@ -1,17 +1,17 @@ { "settings.common.save": "保存", - "settings.common.enterTerminal": "进入终端", - "settings.server.domain.title": "域名设置", - "settings.server.domain.description": "添加域名到服务器", + "settings.common.enterTerminal": "终端", + "settings.server.domain.title": "服务器域名", + "settings.server.domain.description": "为您的服务器应用添加域名。", "settings.server.domain.form.domain": "域名", "settings.server.domain.form.letsEncryptEmail": "Let's Encrypt 邮箱", - "settings.server.domain.form.certificate.label": "证书", - "settings.server.domain.form.certificate.placeholder": "选择一个证书", + "settings.server.domain.form.certificate.label": "证书提供商", + "settings.server.domain.form.certificate.placeholder": "选择证书", "settings.server.domain.form.certificateOptions.none": "无", "settings.server.domain.form.certificateOptions.letsencrypt": "Let's Encrypt", - "settings.server.webServer.title": "服务器设置", - "settings.server.webServer.description": "管理服务器", + "settings.server.webServer.title": "Web 服务器", + "settings.server.webServer.description": "重载或清理 Web 服务器。", "settings.server.webServer.actions": "操作", "settings.server.webServer.reload": "重新加载", "settings.server.webServer.watchLogs": "查看日志", @@ -19,40 +19,40 @@ "settings.server.webServer.server.label": "服务器", "settings.server.webServer.traefik.label": "Traefik", "settings.server.webServer.traefik.modifyEnv": "修改环境变量", - "settings.server.webServer.traefik.managePorts": "端口转发", - "settings.server.webServer.traefik.managePortsDescription": "添加或删除 Traefik 的其他端口", + "settings.server.webServer.traefik.managePorts": "额外端口映射", + "settings.server.webServer.traefik.managePortsDescription": "为 Traefik 添加或删除额外端口", "settings.server.webServer.traefik.targetPort": "目标端口", - "settings.server.webServer.traefik.publishedPort": "对外端口", + "settings.server.webServer.traefik.publishedPort": "发布端口", "settings.server.webServer.traefik.addPort": "添加端口", "settings.server.webServer.traefik.portsUpdated": "端口更新成功", "settings.server.webServer.traefik.portsUpdateError": "端口更新失败", - "settings.server.webServer.traefik.publishMode": "端口映射", + "settings.server.webServer.traefik.publishMode": "发布模式", "settings.server.webServer.storage.label": "存储空间", "settings.server.webServer.storage.cleanUnusedImages": "清理未使用的镜像", "settings.server.webServer.storage.cleanUnusedVolumes": "清理未使用的卷", "settings.server.webServer.storage.cleanStoppedContainers": "清理已停止的容器", - "settings.server.webServer.storage.cleanDockerBuilder": "清理 Docker Builder 与 系统缓存", + "settings.server.webServer.storage.cleanDockerBuilder": "清理 Docker Builder 和系统", "settings.server.webServer.storage.cleanMonitoring": "清理监控数据", "settings.server.webServer.storage.cleanAll": "清理所有内容", "settings.profile.title": "账户", - "settings.profile.description": "更改您的个人资料", + "settings.profile.description": "在此更改您的个人资料详情。", "settings.profile.email": "邮箱", "settings.profile.password": "密码", "settings.profile.avatar": "头像", "settings.appearance.title": "外观", - "settings.appearance.description": "自定义面板主题", + "settings.appearance.description": "自定义您的仪表盘主题。", "settings.appearance.theme": "主题", - "settings.appearance.themeDescription": "选择面板主题", + "settings.appearance.themeDescription": "为您的仪表盘选择主题", "settings.appearance.themes.light": "明亮", - "settings.appearance.themes.dark": "黑暗", - "settings.appearance.themes.system": "系统主题", + "settings.appearance.themes.dark": "暗黑", + "settings.appearance.themes.system": "跟随系统", "settings.appearance.language": "语言", - "settings.appearance.languageDescription": "选择面板语言", + "settings.appearance.languageDescription": "为您的仪表盘选择语言", - "settings.terminal.connectionSettings": "终端设置", - "settings.terminal.ipAddress": "IP", + "settings.terminal.connectionSettings": "连接设置", + "settings.terminal.ipAddress": "IP 地址", "settings.terminal.port": "端口", "settings.terminal.username": "用户名" } From 7ac74813435ddcdf8e8bcc43cae7a921d4897489 Mon Sep 17 00:00:00 2001 From: Hoofei Date: Sun, 6 Apr 2025 12:34:47 +0800 Subject: [PATCH 02/14] Update Simplified Chinese --- .../public/locales/zh-Hans/common.json | 17 +- .../public/locales/zh-Hans/settings.json | 123 ++++---- extract.js | 270 ++++++++++++++++++ merge-translations.js | 252 ++++++++++++++++ 4 files changed, 589 insertions(+), 73 deletions(-) create mode 100644 extract.js create mode 100644 merge-translations.js diff --git a/apps/dokploy/public/locales/zh-Hans/common.json b/apps/dokploy/public/locales/zh-Hans/common.json index 67797618..d8faad7d 100644 --- a/apps/dokploy/public/locales/zh-Hans/common.json +++ b/apps/dokploy/public/locales/zh-Hans/common.json @@ -13,7 +13,6 @@ "dashboard.images": "镜像", "dashboard.volumes": "卷", "dashboard.networks": "网络", - "button.create": "创建", "button.edit": "编辑", "button.delete": "删除", @@ -23,71 +22,57 @@ "button.back": "返回", "button.next": "下一步", "button.finish": "完成", - "status.running": "运行中", "status.stopped": "已停止", "status.error": "错误", "status.pending": "等待中", "status.success": "成功", "status.failed": "失败", - "form.required": "必填", "form.invalid": "无效", "form.submit": "提交", "form.reset": "重置", - "notification.success": "操作成功", "notification.error": "操作失败", "notification.warning": "警告", "notification.info": "信息", - "time.now": "刚刚", "time.minutes": "分钟前", "time.hours": "小时前", "time.days": "天前", - "filter.all": "全部", "filter.active": "活跃", "filter.inactive": "不活跃", - "sort.asc": "升序", "sort.desc": "降序", - "search.placeholder": "搜索...", "search.noResults": "无结果", - "pagination.prev": "上一页", "pagination.next": "下一页", "pagination.of": "共 {0} 页", - "error.notFound": "未找到", "error.serverError": "服务器错误", "error.unauthorized": "未授权", "error.forbidden": "禁止访问", - "loading": "加载中...", "empty": "暂无数据", "more": "更多", "less": "收起", - "project.create": "创建项目", "project.edit": "编辑项目", "project.delete": "删除项目", "project.name": "项目名称", "project.description": "项目描述", - "service.create": "创建服务", "service.edit": "编辑服务", "service.delete": "删除服务", "service.name": "服务名称", "service.type": "服务类型", - "domain.add": "添加域名", "domain.remove": "移除域名", - "environment.variables": "环境变量", "environment.add": "添加环境变量", "environment.edit": "编辑环境变量", "environment.name": "变量名", "environment.value": "变量值" -} +} \ No newline at end of file diff --git a/apps/dokploy/public/locales/zh-Hans/settings.json b/apps/dokploy/public/locales/zh-Hans/settings.json index f7e8a38a..06033238 100644 --- a/apps/dokploy/public/locales/zh-Hans/settings.json +++ b/apps/dokploy/public/locales/zh-Hans/settings.json @@ -1,58 +1,67 @@ { - "settings.common.save": "保存", - "settings.common.enterTerminal": "终端", - "settings.server.domain.title": "服务器域名", - "settings.server.domain.description": "为您的服务器应用添加域名。", - "settings.server.domain.form.domain": "域名", - "settings.server.domain.form.letsEncryptEmail": "Let's Encrypt 邮箱", - "settings.server.domain.form.certificate.label": "证书提供商", - "settings.server.domain.form.certificate.placeholder": "选择证书", - "settings.server.domain.form.certificateOptions.none": "无", - "settings.server.domain.form.certificateOptions.letsencrypt": "Let's Encrypt", - - "settings.server.webServer.title": "Web 服务器", - "settings.server.webServer.description": "重载或清理 Web 服务器。", - "settings.server.webServer.actions": "操作", - "settings.server.webServer.reload": "重新加载", - "settings.server.webServer.watchLogs": "查看日志", - "settings.server.webServer.updateServerIp": "更新服务器 IP", - "settings.server.webServer.server.label": "服务器", - "settings.server.webServer.traefik.label": "Traefik", - "settings.server.webServer.traefik.modifyEnv": "修改环境变量", - "settings.server.webServer.traefik.managePorts": "额外端口映射", - "settings.server.webServer.traefik.managePortsDescription": "为 Traefik 添加或删除额外端口", - "settings.server.webServer.traefik.targetPort": "目标端口", - "settings.server.webServer.traefik.publishedPort": "发布端口", - "settings.server.webServer.traefik.addPort": "添加端口", - "settings.server.webServer.traefik.portsUpdated": "端口更新成功", - "settings.server.webServer.traefik.portsUpdateError": "端口更新失败", - "settings.server.webServer.traefik.publishMode": "发布模式", - "settings.server.webServer.storage.label": "存储空间", - "settings.server.webServer.storage.cleanUnusedImages": "清理未使用的镜像", - "settings.server.webServer.storage.cleanUnusedVolumes": "清理未使用的卷", - "settings.server.webServer.storage.cleanStoppedContainers": "清理已停止的容器", - "settings.server.webServer.storage.cleanDockerBuilder": "清理 Docker Builder 和系统", - "settings.server.webServer.storage.cleanMonitoring": "清理监控数据", - "settings.server.webServer.storage.cleanAll": "清理所有内容", - - "settings.profile.title": "账户", - "settings.profile.description": "在此更改您的个人资料详情。", - "settings.profile.email": "邮箱", - "settings.profile.password": "密码", - "settings.profile.avatar": "头像", - - "settings.appearance.title": "外观", - "settings.appearance.description": "自定义您的仪表盘主题。", - "settings.appearance.theme": "主题", - "settings.appearance.themeDescription": "为您的仪表盘选择主题", - "settings.appearance.themes.light": "明亮", - "settings.appearance.themes.dark": "暗黑", - "settings.appearance.themes.system": "跟随系统", - "settings.appearance.language": "语言", - "settings.appearance.languageDescription": "为您的仪表盘选择语言", - - "settings.terminal.connectionSettings": "连接设置", - "settings.terminal.ipAddress": "IP 地址", - "settings.terminal.port": "端口", - "settings.terminal.username": "用户名" -} + "settings.common.save": "保存", + "settings.common.enterTerminal": "终端", + "settings.server.domain.title": "服务器域名", + "settings.server.domain.description": "为您的服务器应用添加域名。", + "settings.server.domain.form.domain": "域名", + "settings.server.domain.form.letsEncryptEmail": "Let's Encrypt 邮箱", + "settings.server.domain.form.certificate.label": "证书提供商", + "settings.server.domain.form.certificate.placeholder": "选择证书", + "settings.server.domain.form.certificateOptions.none": "无", + "settings.server.domain.form.certificateOptions.letsencrypt": "Let's Encrypt", + "settings.server.webServer.title": "Web 服务器", + "settings.server.webServer.description": "重载或清理 Web 服务器。", + "settings.server.webServer.actions": "操作", + "settings.server.webServer.reload": "重新加载", + "settings.server.webServer.watchLogs": "查看日志", + "settings.server.webServer.updateServerIp": "更新服务器 IP", + "settings.server.webServer.server.label": "服务器", + "settings.server.webServer.traefik.label": "Traefik", + "settings.server.webServer.traefik.modifyEnv": "修改环境变量", + "settings.server.webServer.traefik.managePorts": "额外端口映射", + "settings.server.webServer.traefik.managePortsDescription": "为 Traefik 添加或删除额外端口", + "settings.server.webServer.traefik.targetPort": "目标端口", + "settings.server.webServer.traefik.publishedPort": "发布端口", + "settings.server.webServer.traefik.addPort": "添加端口", + "settings.server.webServer.traefik.portsUpdated": "端口更新成功", + "settings.server.webServer.traefik.portsUpdateError": "端口更新失败", + "settings.server.webServer.traefik.publishMode": "发布模式", + "settings.server.webServer.storage.label": "存储空间", + "settings.server.webServer.storage.cleanUnusedImages": "清理未使用的镜像", + "settings.server.webServer.storage.cleanUnusedVolumes": "清理未使用的卷", + "settings.server.webServer.storage.cleanStoppedContainers": "清理已停止的容器", + "settings.server.webServer.storage.cleanDockerBuilder": "清理 Docker Builder 和系统", + "settings.server.webServer.storage.cleanMonitoring": "清理监控数据", + "settings.server.webServer.storage.cleanAll": "清理所有内容", + "settings.profile.title": "账户", + "settings.profile.description": "在此更改您的个人资料详情。", + "settings.profile.email": "邮箱", + "settings.profile.password": "密码", + "settings.profile.avatar": "头像", + "settings.appearance.title": "外观", + "settings.appearance.description": "自定义您的仪表盘主题。", + "settings.appearance.theme": "主题", + "settings.appearance.themeDescription": "为您的仪表盘选择主题", + "settings.appearance.themes.light": "明亮", + "settings.appearance.themes.dark": "暗黑", + "settings.appearance.themes.system": "跟随系统", + "settings.appearance.language": "语言", + "settings.appearance.languageDescription": "为您的仪表盘选择语言", + "settings.terminal.connectionSettings": "连接设置", + "settings.terminal.ipAddress": "IP 地址", + "settings.terminal.port": "端口", + "settings.terminal.username": "用户名", + "settings.settings": "设置", + "settings.general": "通用设置", + "settings.security": "安全", + "settings.users": "用户管理", + "settings.roles": "角色管理", + "settings.permissions": "权限", + "settings.api": "API设置", + "settings.certificates": "证书管理", + "settings.ssh": "SSH密钥", + "settings.backups": "备份", + "settings.logs": "日志", + "settings.updates": "更新", + "settings.network": "网络" +} \ No newline at end of file diff --git a/extract.js b/extract.js new file mode 100644 index 00000000..61d5d2d7 --- /dev/null +++ b/extract.js @@ -0,0 +1,270 @@ +console.log('Creating translation extractor script...'); + +const fs = require('fs'); +const path = require('path'); + +// 存储找到的所有翻译键 +const translationKeys = { + common: new Set(), + settings: new Set() +}; + +// 匹配更多格式的翻译函数调用 +// 支持 t('common.xxx')、t("common.xxx")、t(`common.xxx`) +const translationPatterns = [ + /t\(\s*['"]([a-zA-Z0-9._-]+)['"]?\s*[,)]/g, // t('key') 或 t("key") + /t\(\s*`([a-zA-Z0-9._-]+)`\s*[,)]/g, // t(`key`) + /useTranslation\(\s*["']([a-zA-Z0-9._-]+)["']\s*\)/g, // useTranslation('namespace') + /serverSideTranslations\([^)]*["']([a-zA-Z0-9._-]+)["']/g // serverSideTranslations(..., ['namespace']) +]; + +const namespaceRegex = /^(common|settings)\./; + +// 递归扫描目录下的所有 JS 和 TS 文件 +function scanDirectory(directory) { + try { + const entries = fs.readdirSync(directory, { withFileTypes: true }); + + for (const entry of entries) { + const fullPath = path.join(directory, entry.name); + + if (entry.isDirectory() && !fullPath.includes('node_modules') && !fullPath.includes('.next')) { + scanDirectory(fullPath); + } else if (entry.isFile() && /\.(js|jsx|ts|tsx)$/.test(entry.name)) { + try { + const content = fs.readFileSync(fullPath, 'utf8'); + + // 检查文件中是否使用了翻译 + let usesTranslation = false; + if (content.includes('useTranslation') || content.includes('t(') || content.includes('serverSideTranslations')) { + usesTranslation = true; + } + + if (usesTranslation) { + // 使用所有模式匹配翻译键 + for (const pattern of translationPatterns) { + let match; + while ((match = pattern.exec(content)) !== null) { + const key = match[1]; + + // 检查是否有命名空间 + const namespaceMatch = key.match(namespaceRegex); + if (namespaceMatch) { + const namespace = namespaceMatch[1]; + if (namespace === 'common' || namespace === 'settings') { + translationKeys[namespace].add(key); + } + } + + // 如果文件中导入了特定命名空间,所有的 t(key) 都属于该命名空间 + if (content.includes(`useTranslation('common')`) || content.includes(`useTranslation("common")`)) { + if (!key.includes('.')) { + translationKeys.common.add(`common.${key}`); + } + } + + if (content.includes(`useTranslation('settings')`) || content.includes(`useTranslation("settings")`)) { + if (!key.includes('.')) { + translationKeys.settings.add(`settings.${key}`); + } + } + } + } + + // 控制台输出被处理的文件及其找到的翻译键 + if (usesTranslation) { + console.log(`检查文件: ${fullPath}`); + } + } + } catch (error) { + console.error(`Error reading file ${fullPath}:`, error); + } + } + } + } catch (error) { + console.error(`Error scanning directory ${directory}:`, error); + } +} + +// 手动添加一些常见的翻译键(基于直接观察和常见用法) +function addCommonTranslationKeys() { + const commonKeys = [ + 'dashboard.title', 'dashboard.overview', 'dashboard.projects', 'dashboard.servers', + 'dashboard.docker', 'dashboard.monitoring', 'dashboard.settings', 'dashboard.logout', + 'dashboard.profile', 'dashboard.terminal', 'dashboard.containers', 'dashboard.images', + 'dashboard.volumes', 'dashboard.networks', + + 'button.create', 'button.edit', 'button.delete', 'button.cancel', + 'button.save', 'button.confirm', 'button.back', 'button.next', 'button.finish', + + 'status.running', 'status.stopped', 'status.error', 'status.pending', + 'status.success', 'status.failed', + + 'form.required', 'form.invalid', 'form.submit', 'form.reset', + + 'notification.success', 'notification.error', 'notification.warning', 'notification.info', + + 'time.now', 'time.minutes', 'time.hours', 'time.days', + + 'filter.all', 'filter.active', 'filter.inactive', + + 'sort.asc', 'sort.desc', + + 'search.placeholder', 'search.noResults', + + 'pagination.prev', 'pagination.next', 'pagination.of', + + 'error.notFound', 'error.serverError', 'error.unauthorized', 'error.forbidden', + + 'loading', 'empty', 'more', 'less', + + 'project.create', 'project.edit', 'project.delete', 'project.name', 'project.description', + + 'service.create', 'service.edit', 'service.delete', 'service.name', 'service.type', + + 'domain.add', 'domain.remove', + + 'environment.variables', 'environment.add', 'environment.edit', + 'environment.name', 'environment.value' + ]; + + commonKeys.forEach(key => { + translationKeys.common.add(`common.${key}`); + }); +} + +// 读取现有翻译文件 +function readTranslationFile(filePath) { + try { + if (fs.existsSync(filePath)) { + const content = fs.readFileSync(filePath, 'utf8'); + return JSON.parse(content); + } + } catch (error) { + console.error(`Error reading translation file ${filePath}:`, error); + } + return {}; +} + +// 主函数 +function extractTranslations() { + const appsDir = path.join(__dirname, 'apps', 'dokploy'); + + // 扫描代码库 + scanDirectory(appsDir); + + // 手动添加常见的翻译键 + addCommonTranslationKeys(); + + // 读取现有翻译文件 + const zhHansCommonPath = path.join(appsDir, 'public', 'locales', 'zh-Hans', 'common.json'); + const zhHansSettingsPath = path.join(appsDir, 'public', 'locales', 'zh-Hans', 'settings.json'); + + const existingCommon = readTranslationFile(zhHansCommonPath); + const existingSettings = readTranslationFile(zhHansSettingsPath); + + // 准备新的翻译文件 + const newCommon = {}; + const newSettings = {}; + + // 处理 common 命名空间 + for (const key of translationKeys.common) { + const shortKey = key.replace('common.', ''); + newCommon[key] = existingCommon[key] || `[需要翻译] ${shortKey}`; + } + + // 处理 settings 命名空间 + for (const key of translationKeys.settings) { + const shortKey = key.replace('settings.', ''); + newSettings[key] = existingSettings[key] || `[需要翻译] ${shortKey}`; + } + + // 输出结果 + console.log('=== 提取的 common 翻译键 ==='); + console.log(Array.from(translationKeys.common).sort().join('\n')); + console.log(`\n共找到 ${translationKeys.common.size} 个 common 翻译键`); + + console.log('\n=== 提取的 settings 翻译键 ==='); + console.log(Array.from(translationKeys.settings).sort().join('\n')); + console.log(`\n共找到 ${translationKeys.settings.size} 个 settings 翻译键`); + + // 创建包含缺失翻译的新文件 + const missingCommonTranslations = {}; + const missingSettingsTranslations = {}; + + for (const key of translationKeys.common) { + if (!existingCommon[key]) { + const shortKey = key.replace('common.', ''); + missingCommonTranslations[key] = `[需要翻译] ${shortKey}`; + } + } + + for (const key of translationKeys.settings) { + if (!existingSettings[key]) { + const shortKey = key.replace('settings.', ''); + missingSettingsTranslations[key] = `[需要翻译] ${shortKey}`; + } + } + + // 输出缺失的翻译 + console.log('\n=== 缺失的 common 翻译 ==='); + console.log(JSON.stringify(missingCommonTranslations, null, 2)); + console.log(`\n共缺失 ${Object.keys(missingCommonTranslations).length} 个 common 翻译`); + + console.log('\n=== 缺失的 settings 翻译 ==='); + console.log(JSON.stringify(missingSettingsTranslations, null, 2)); + console.log(`\n共缺失 ${Object.keys(missingSettingsTranslations).length} 个 settings 翻译`); + + // 输出可以直接复制到文件中的完整翻译对象 + console.log('\n=== 完整的 common.json 内容 ==='); + const fullCommon = { ...existingCommon }; + translationKeys.common.forEach(key => { + if (!fullCommon[key]) { + const shortKey = key.replace('common.', ''); + fullCommon[key] = `[翻译] ${shortKey}`; + } + }); + console.log(JSON.stringify(fullCommon, null, 2)); + + console.log('\n=== 完整的 settings.json 内容 ==='); + const fullSettings = { ...existingSettings }; + translationKeys.settings.forEach(key => { + if (!fullSettings[key]) { + const shortKey = key.replace('settings.', ''); + fullSettings[key] = `[翻译] ${shortKey}`; + } + }); + console.log(JSON.stringify(fullSettings, null, 2)); + + // 优化生成的翻译文件格式:移除命名空间前缀 + const optimizedCommon = {}; + Object.keys(fullCommon).forEach(key => { + const shortKey = key.replace('common.', ''); + optimizedCommon[shortKey] = fullCommon[key]; + }); + + const optimizedSettings = {}; + Object.keys(fullSettings).forEach(key => { + const shortKey = key.replace('settings.', ''); + optimizedSettings[shortKey] = fullSettings[key]; + }); + + // 写入文件 + fs.writeFileSync('missing-common-translations.json', JSON.stringify(missingCommonTranslations, null, 2), 'utf8'); + fs.writeFileSync('missing-settings-translations.json', JSON.stringify(missingSettingsTranslations, null, 2), 'utf8'); + fs.writeFileSync('full-common-translations.json', JSON.stringify(fullCommon, null, 2), 'utf8'); + fs.writeFileSync('full-settings-translations.json', JSON.stringify(fullSettings, null, 2), 'utf8'); + fs.writeFileSync('optimized-common-translations.json', JSON.stringify(optimizedCommon, null, 2), 'utf8'); + fs.writeFileSync('optimized-settings-translations.json', JSON.stringify(optimizedSettings, null, 2), 'utf8'); + + console.log('\n翻译提取完成!'); + console.log('文件已保存:'); + console.log('- missing-common-translations.json: 缺失的 common 翻译'); + console.log('- missing-settings-translations.json: 缺失的 settings 翻译'); + console.log('- full-common-translations.json: 完整的 common 翻译(包含命名空间)'); + console.log('- full-settings-translations.json: 完整的 settings 翻译(包含命名空间)'); + console.log('- optimized-common-translations.json: 优化格式的 common 翻译(不含命名空间)'); + console.log('- optimized-settings-translations.json: 优化格式的 settings 翻译(不含命名空间)'); +} + +extractTranslations(); diff --git a/merge-translations.js b/merge-translations.js new file mode 100644 index 00000000..441ebed4 --- /dev/null +++ b/merge-translations.js @@ -0,0 +1,252 @@ +// 读取已创建的翻译文件 +const fs = require('fs'); +const path = require('path'); + +try { + const basePath = process.cwd(); + const commonPart1Path = path.join(basePath, 'common-zh-Hans.json'); + const commonPart2Path = path.join(basePath, 'common-zh-Hans-buttons.json'); + const fullCommonPath = path.join(basePath, 'optimized-common-translations.json'); + const fullSettingsPath = path.join(basePath, 'optimized-settings-translations.json'); + + const commonPart1 = JSON.parse(fs.readFileSync(commonPart1Path, 'utf8')); + const commonPart2 = JSON.parse(fs.readFileSync(commonPart2Path, 'utf8')); + const fullCommon = JSON.parse(fs.readFileSync(fullCommonPath, 'utf8')); + const fullSettings = JSON.parse(fs.readFileSync(fullSettingsPath, 'utf8')); + + // 创建一个全新的翻译对象 + const mergedCommon = {}; + const mergedSettings = {}; + + // 添加通用组件翻译 + mergedCommon["dashboard.title"] = "仪表盘"; + mergedCommon["dashboard.overview"] = "概览"; + mergedCommon["dashboard.projects"] = "项目"; + mergedCommon["dashboard.servers"] = "服务器"; + mergedCommon["dashboard.docker"] = "Docker"; + mergedCommon["dashboard.monitoring"] = "监控"; + mergedCommon["dashboard.settings"] = "设置"; + mergedCommon["dashboard.logout"] = "退出登录"; + mergedCommon["dashboard.profile"] = "个人资料"; + mergedCommon["dashboard.terminal"] = "终端"; + mergedCommon["dashboard.containers"] = "容器"; + mergedCommon["dashboard.images"] = "镜像"; + mergedCommon["dashboard.volumes"] = "卷"; + mergedCommon["dashboard.networks"] = "网络"; + + // 按钮翻译 + mergedCommon["button.create"] = "创建"; + mergedCommon["button.edit"] = "编辑"; + mergedCommon["button.delete"] = "删除"; + mergedCommon["button.cancel"] = "取消"; + mergedCommon["button.save"] = "保存"; + mergedCommon["button.confirm"] = "确认"; + mergedCommon["button.back"] = "返回"; + mergedCommon["button.next"] = "下一步"; + mergedCommon["button.finish"] = "完成"; + + // 状态翻译 + mergedCommon["status.running"] = "运行中"; + mergedCommon["status.stopped"] = "已停止"; + mergedCommon["status.error"] = "错误"; + mergedCommon["status.pending"] = "等待中"; + mergedCommon["status.success"] = "成功"; + mergedCommon["status.failed"] = "失败"; + + // 表单翻译 + mergedCommon["form.required"] = "必填"; + mergedCommon["form.invalid"] = "无效"; + mergedCommon["form.submit"] = "提交"; + mergedCommon["form.reset"] = "重置"; + + // 通知翻译 + mergedCommon["notification.success"] = "操作成功"; + mergedCommon["notification.error"] = "操作失败"; + mergedCommon["notification.warning"] = "警告"; + mergedCommon["notification.info"] = "信息"; + + // 时间翻译 + mergedCommon["time.now"] = "刚刚"; + mergedCommon["time.minutes"] = "分钟前"; + mergedCommon["time.hours"] = "小时前"; + mergedCommon["time.days"] = "天前"; + + // 过滤翻译 + mergedCommon["filter.all"] = "全部"; + mergedCommon["filter.active"] = "活跃"; + mergedCommon["filter.inactive"] = "不活跃"; + + // 排序翻译 + mergedCommon["sort.asc"] = "升序"; + mergedCommon["sort.desc"] = "降序"; + + // 搜索翻译 + mergedCommon["search.placeholder"] = "搜索..."; + mergedCommon["search.noResults"] = "无结果"; + + // 分页翻译 + mergedCommon["pagination.prev"] = "上一页"; + mergedCommon["pagination.next"] = "下一页"; + mergedCommon["pagination.of"] = "共 {0} 页"; + + // 错误翻译 + mergedCommon["error.notFound"] = "未找到"; + mergedCommon["error.serverError"] = "服务器错误"; + mergedCommon["error.unauthorized"] = "未授权"; + mergedCommon["error.forbidden"] = "禁止访问"; + + // 通用状态翻译 + mergedCommon["loading"] = "加载中..."; + mergedCommon["empty"] = "暂无数据"; + mergedCommon["more"] = "更多"; + mergedCommon["less"] = "收起"; + + // 项目翻译 + mergedCommon["project.create"] = "创建项目"; + mergedCommon["project.edit"] = "编辑项目"; + mergedCommon["project.delete"] = "删除项目"; + mergedCommon["project.name"] = "项目名称"; + mergedCommon["project.description"] = "项目描述"; + + // 服务翻译 + mergedCommon["service.create"] = "创建服务"; + mergedCommon["service.edit"] = "编辑服务"; + mergedCommon["service.delete"] = "删除服务"; + mergedCommon["service.name"] = "服务名称"; + mergedCommon["service.type"] = "服务类型"; + + // 域名翻译 + mergedCommon["domain.add"] = "添加域名"; + mergedCommon["domain.remove"] = "移除域名"; + + // 环境变量翻译 + mergedCommon["environment.variables"] = "环境变量"; + mergedCommon["environment.add"] = "添加环境变量"; + mergedCommon["environment.edit"] = "编辑环境变量"; + mergedCommon["environment.name"] = "变量名"; + mergedCommon["environment.value"] = "变量值"; + + // 设置页面的通用翻译 + mergedSettings["common.save"] = "保存"; + mergedSettings["common.enterTerminal"] = "终端"; + + // 服务器域名设置 + mergedSettings["server.domain.title"] = "服务器域名"; + mergedSettings["server.domain.description"] = "为您的服务器应用添加域名。"; + mergedSettings["server.domain.form.domain"] = "域名"; + mergedSettings["server.domain.form.letsEncryptEmail"] = "Let's Encrypt 邮箱"; + mergedSettings["server.domain.form.certificate.label"] = "证书提供商"; + mergedSettings["server.domain.form.certificate.placeholder"] = "选择证书"; + mergedSettings["server.domain.form.certificateOptions.none"] = "无"; + mergedSettings["server.domain.form.certificateOptions.letsencrypt"] = "Let's Encrypt"; + + // Web服务器设置 + mergedSettings["server.webServer.title"] = "Web 服务器"; + mergedSettings["server.webServer.description"] = "重载或清理 Web 服务器。"; + mergedSettings["server.webServer.actions"] = "操作"; + mergedSettings["server.webServer.reload"] = "重新加载"; + mergedSettings["server.webServer.watchLogs"] = "查看日志"; + mergedSettings["server.webServer.updateServerIp"] = "更新服务器 IP"; + mergedSettings["server.webServer.server.label"] = "服务器"; + + // Traefik设置 + mergedSettings["server.webServer.traefik.label"] = "Traefik"; + mergedSettings["server.webServer.traefik.modifyEnv"] = "修改环境变量"; + mergedSettings["server.webServer.traefik.managePorts"] = "额外端口映射"; + mergedSettings["server.webServer.traefik.managePortsDescription"] = "为 Traefik 添加或删除额外端口"; + mergedSettings["server.webServer.traefik.targetPort"] = "目标端口"; + mergedSettings["server.webServer.traefik.publishedPort"] = "发布端口"; + mergedSettings["server.webServer.traefik.addPort"] = "添加端口"; + mergedSettings["server.webServer.traefik.portsUpdated"] = "端口更新成功"; + mergedSettings["server.webServer.traefik.portsUpdateError"] = "端口更新失败"; + mergedSettings["server.webServer.traefik.publishMode"] = "发布模式"; + + // 存储空间设置 + mergedSettings["server.webServer.storage.label"] = "存储空间"; + mergedSettings["server.webServer.storage.cleanUnusedImages"] = "清理未使用的镜像"; + mergedSettings["server.webServer.storage.cleanUnusedVolumes"] = "清理未使用的卷"; + mergedSettings["server.webServer.storage.cleanStoppedContainers"] = "清理已停止的容器"; + mergedSettings["server.webServer.storage.cleanDockerBuilder"] = "清理 Docker Builder 和系统"; + mergedSettings["server.webServer.storage.cleanMonitoring"] = "清理监控数据"; + mergedSettings["server.webServer.storage.cleanAll"] = "清理所有内容"; + + // 个人资料设置 + mergedSettings["profile.title"] = "账户"; + mergedSettings["profile.description"] = "在此更改您的个人资料详情。"; + mergedSettings["profile.email"] = "邮箱"; + mergedSettings["profile.password"] = "密码"; + mergedSettings["profile.avatar"] = "头像"; + + // 外观设置 + mergedSettings["appearance.title"] = "外观"; + mergedSettings["appearance.description"] = "自定义您的仪表盘主题。"; + mergedSettings["appearance.theme"] = "主题"; + mergedSettings["appearance.themeDescription"] = "为您的仪表盘选择主题"; + mergedSettings["appearance.themes.light"] = "明亮"; + mergedSettings["appearance.themes.dark"] = "暗黑"; + mergedSettings["appearance.themes.system"] = "跟随系统"; + mergedSettings["appearance.language"] = "语言"; + mergedSettings["appearance.languageDescription"] = "为您的仪表盘选择语言"; + + // 终端设置 + mergedSettings["terminal.connectionSettings"] = "连接设置"; + mergedSettings["terminal.ipAddress"] = "IP 地址"; + mergedSettings["terminal.port"] = "端口"; + mergedSettings["terminal.username"] = "用户名"; + + // 其他设置 + mergedSettings["settings"] = "设置"; + mergedSettings["general"] = "通用设置"; + mergedSettings["security"] = "安全"; + mergedSettings["users"] = "用户管理"; + mergedSettings["roles"] = "角色管理"; + mergedSettings["permissions"] = "权限"; + mergedSettings["api"] = "API设置"; + mergedSettings["certificates"] = "证书管理"; + mergedSettings["ssh"] = "SSH密钥"; + mergedSettings["backups"] = "备份"; + mergedSettings["logs"] = "日志"; + mergedSettings["updates"] = "更新"; + mergedSettings["network"] = "网络"; + + // 输出合并后的文件内容 + console.log('Common translations total:', Object.keys(mergedCommon).length); + console.log('Settings translations total:', Object.keys(mergedSettings).length); + + // 保存为最终的翻译文件 + fs.writeFileSync(path.join(basePath, 'final-zh-Hans-common.json'), JSON.stringify(mergedCommon, null, 2)); + fs.writeFileSync(path.join(basePath, 'final-zh-Hans-settings.json'), JSON.stringify(mergedSettings, null, 2)); + + // 输出翻译完成的统计 + const commonKeys = Object.keys(mergedCommon); + const settingsKeys = Object.keys(mergedSettings); + console.log('最终翻译文件已保存:'); + console.log(`- 通用翻译 (${commonKeys.length} 个词条)`); + console.log(`- 设置翻译 (${settingsKeys.length} 个词条)`); + + // 创建最终放入项目中的文件(按项目结构) + const projectCommonPath = path.join(basePath, 'apps', 'dokploy', 'public', 'locales', 'zh-Hans'); + + // 确保目录存在 + if (!fs.existsSync(projectCommonPath)) { + fs.mkdirSync(projectCommonPath, { recursive: true }); + console.log(`创建目录: ${projectCommonPath}`); + } + + // 写入到项目中的目标位置 + const projectCommonFilePath = path.join(projectCommonPath, 'common.json'); + const projectSettingsFilePath = path.join(projectCommonPath, 'settings.json'); + + console.log(`尝试写入到:\n- ${projectCommonFilePath}\n- ${projectSettingsFilePath}`); + + try { + fs.writeFileSync(projectCommonFilePath, JSON.stringify(mergedCommon, null, 2)); + fs.writeFileSync(projectSettingsFilePath, JSON.stringify(mergedSettings, null, 2)); + console.log('已成功写入到项目文件夹中!'); + } catch (error) { + console.error('写入到项目文件夹失败:', error.message); + console.log('请手动将文件复制到目标位置。'); + } +} catch (error) { + console.error('错误:', error); +} From 350bed217c5574ed829999a6a9996770dee36227 Mon Sep 17 00:00:00 2001 From: Hoofei Date: Sun, 6 Apr 2025 12:37:52 +0800 Subject: [PATCH 03/14] Delete the extract script --- extract.js | 270 ------------------------------------------ merge-translations.js | 252 --------------------------------------- 2 files changed, 522 deletions(-) delete mode 100644 extract.js delete mode 100644 merge-translations.js diff --git a/extract.js b/extract.js deleted file mode 100644 index 61d5d2d7..00000000 --- a/extract.js +++ /dev/null @@ -1,270 +0,0 @@ -console.log('Creating translation extractor script...'); - -const fs = require('fs'); -const path = require('path'); - -// 存储找到的所有翻译键 -const translationKeys = { - common: new Set(), - settings: new Set() -}; - -// 匹配更多格式的翻译函数调用 -// 支持 t('common.xxx')、t("common.xxx")、t(`common.xxx`) -const translationPatterns = [ - /t\(\s*['"]([a-zA-Z0-9._-]+)['"]?\s*[,)]/g, // t('key') 或 t("key") - /t\(\s*`([a-zA-Z0-9._-]+)`\s*[,)]/g, // t(`key`) - /useTranslation\(\s*["']([a-zA-Z0-9._-]+)["']\s*\)/g, // useTranslation('namespace') - /serverSideTranslations\([^)]*["']([a-zA-Z0-9._-]+)["']/g // serverSideTranslations(..., ['namespace']) -]; - -const namespaceRegex = /^(common|settings)\./; - -// 递归扫描目录下的所有 JS 和 TS 文件 -function scanDirectory(directory) { - try { - const entries = fs.readdirSync(directory, { withFileTypes: true }); - - for (const entry of entries) { - const fullPath = path.join(directory, entry.name); - - if (entry.isDirectory() && !fullPath.includes('node_modules') && !fullPath.includes('.next')) { - scanDirectory(fullPath); - } else if (entry.isFile() && /\.(js|jsx|ts|tsx)$/.test(entry.name)) { - try { - const content = fs.readFileSync(fullPath, 'utf8'); - - // 检查文件中是否使用了翻译 - let usesTranslation = false; - if (content.includes('useTranslation') || content.includes('t(') || content.includes('serverSideTranslations')) { - usesTranslation = true; - } - - if (usesTranslation) { - // 使用所有模式匹配翻译键 - for (const pattern of translationPatterns) { - let match; - while ((match = pattern.exec(content)) !== null) { - const key = match[1]; - - // 检查是否有命名空间 - const namespaceMatch = key.match(namespaceRegex); - if (namespaceMatch) { - const namespace = namespaceMatch[1]; - if (namespace === 'common' || namespace === 'settings') { - translationKeys[namespace].add(key); - } - } - - // 如果文件中导入了特定命名空间,所有的 t(key) 都属于该命名空间 - if (content.includes(`useTranslation('common')`) || content.includes(`useTranslation("common")`)) { - if (!key.includes('.')) { - translationKeys.common.add(`common.${key}`); - } - } - - if (content.includes(`useTranslation('settings')`) || content.includes(`useTranslation("settings")`)) { - if (!key.includes('.')) { - translationKeys.settings.add(`settings.${key}`); - } - } - } - } - - // 控制台输出被处理的文件及其找到的翻译键 - if (usesTranslation) { - console.log(`检查文件: ${fullPath}`); - } - } - } catch (error) { - console.error(`Error reading file ${fullPath}:`, error); - } - } - } - } catch (error) { - console.error(`Error scanning directory ${directory}:`, error); - } -} - -// 手动添加一些常见的翻译键(基于直接观察和常见用法) -function addCommonTranslationKeys() { - const commonKeys = [ - 'dashboard.title', 'dashboard.overview', 'dashboard.projects', 'dashboard.servers', - 'dashboard.docker', 'dashboard.monitoring', 'dashboard.settings', 'dashboard.logout', - 'dashboard.profile', 'dashboard.terminal', 'dashboard.containers', 'dashboard.images', - 'dashboard.volumes', 'dashboard.networks', - - 'button.create', 'button.edit', 'button.delete', 'button.cancel', - 'button.save', 'button.confirm', 'button.back', 'button.next', 'button.finish', - - 'status.running', 'status.stopped', 'status.error', 'status.pending', - 'status.success', 'status.failed', - - 'form.required', 'form.invalid', 'form.submit', 'form.reset', - - 'notification.success', 'notification.error', 'notification.warning', 'notification.info', - - 'time.now', 'time.minutes', 'time.hours', 'time.days', - - 'filter.all', 'filter.active', 'filter.inactive', - - 'sort.asc', 'sort.desc', - - 'search.placeholder', 'search.noResults', - - 'pagination.prev', 'pagination.next', 'pagination.of', - - 'error.notFound', 'error.serverError', 'error.unauthorized', 'error.forbidden', - - 'loading', 'empty', 'more', 'less', - - 'project.create', 'project.edit', 'project.delete', 'project.name', 'project.description', - - 'service.create', 'service.edit', 'service.delete', 'service.name', 'service.type', - - 'domain.add', 'domain.remove', - - 'environment.variables', 'environment.add', 'environment.edit', - 'environment.name', 'environment.value' - ]; - - commonKeys.forEach(key => { - translationKeys.common.add(`common.${key}`); - }); -} - -// 读取现有翻译文件 -function readTranslationFile(filePath) { - try { - if (fs.existsSync(filePath)) { - const content = fs.readFileSync(filePath, 'utf8'); - return JSON.parse(content); - } - } catch (error) { - console.error(`Error reading translation file ${filePath}:`, error); - } - return {}; -} - -// 主函数 -function extractTranslations() { - const appsDir = path.join(__dirname, 'apps', 'dokploy'); - - // 扫描代码库 - scanDirectory(appsDir); - - // 手动添加常见的翻译键 - addCommonTranslationKeys(); - - // 读取现有翻译文件 - const zhHansCommonPath = path.join(appsDir, 'public', 'locales', 'zh-Hans', 'common.json'); - const zhHansSettingsPath = path.join(appsDir, 'public', 'locales', 'zh-Hans', 'settings.json'); - - const existingCommon = readTranslationFile(zhHansCommonPath); - const existingSettings = readTranslationFile(zhHansSettingsPath); - - // 准备新的翻译文件 - const newCommon = {}; - const newSettings = {}; - - // 处理 common 命名空间 - for (const key of translationKeys.common) { - const shortKey = key.replace('common.', ''); - newCommon[key] = existingCommon[key] || `[需要翻译] ${shortKey}`; - } - - // 处理 settings 命名空间 - for (const key of translationKeys.settings) { - const shortKey = key.replace('settings.', ''); - newSettings[key] = existingSettings[key] || `[需要翻译] ${shortKey}`; - } - - // 输出结果 - console.log('=== 提取的 common 翻译键 ==='); - console.log(Array.from(translationKeys.common).sort().join('\n')); - console.log(`\n共找到 ${translationKeys.common.size} 个 common 翻译键`); - - console.log('\n=== 提取的 settings 翻译键 ==='); - console.log(Array.from(translationKeys.settings).sort().join('\n')); - console.log(`\n共找到 ${translationKeys.settings.size} 个 settings 翻译键`); - - // 创建包含缺失翻译的新文件 - const missingCommonTranslations = {}; - const missingSettingsTranslations = {}; - - for (const key of translationKeys.common) { - if (!existingCommon[key]) { - const shortKey = key.replace('common.', ''); - missingCommonTranslations[key] = `[需要翻译] ${shortKey}`; - } - } - - for (const key of translationKeys.settings) { - if (!existingSettings[key]) { - const shortKey = key.replace('settings.', ''); - missingSettingsTranslations[key] = `[需要翻译] ${shortKey}`; - } - } - - // 输出缺失的翻译 - console.log('\n=== 缺失的 common 翻译 ==='); - console.log(JSON.stringify(missingCommonTranslations, null, 2)); - console.log(`\n共缺失 ${Object.keys(missingCommonTranslations).length} 个 common 翻译`); - - console.log('\n=== 缺失的 settings 翻译 ==='); - console.log(JSON.stringify(missingSettingsTranslations, null, 2)); - console.log(`\n共缺失 ${Object.keys(missingSettingsTranslations).length} 个 settings 翻译`); - - // 输出可以直接复制到文件中的完整翻译对象 - console.log('\n=== 完整的 common.json 内容 ==='); - const fullCommon = { ...existingCommon }; - translationKeys.common.forEach(key => { - if (!fullCommon[key]) { - const shortKey = key.replace('common.', ''); - fullCommon[key] = `[翻译] ${shortKey}`; - } - }); - console.log(JSON.stringify(fullCommon, null, 2)); - - console.log('\n=== 完整的 settings.json 内容 ==='); - const fullSettings = { ...existingSettings }; - translationKeys.settings.forEach(key => { - if (!fullSettings[key]) { - const shortKey = key.replace('settings.', ''); - fullSettings[key] = `[翻译] ${shortKey}`; - } - }); - console.log(JSON.stringify(fullSettings, null, 2)); - - // 优化生成的翻译文件格式:移除命名空间前缀 - const optimizedCommon = {}; - Object.keys(fullCommon).forEach(key => { - const shortKey = key.replace('common.', ''); - optimizedCommon[shortKey] = fullCommon[key]; - }); - - const optimizedSettings = {}; - Object.keys(fullSettings).forEach(key => { - const shortKey = key.replace('settings.', ''); - optimizedSettings[shortKey] = fullSettings[key]; - }); - - // 写入文件 - fs.writeFileSync('missing-common-translations.json', JSON.stringify(missingCommonTranslations, null, 2), 'utf8'); - fs.writeFileSync('missing-settings-translations.json', JSON.stringify(missingSettingsTranslations, null, 2), 'utf8'); - fs.writeFileSync('full-common-translations.json', JSON.stringify(fullCommon, null, 2), 'utf8'); - fs.writeFileSync('full-settings-translations.json', JSON.stringify(fullSettings, null, 2), 'utf8'); - fs.writeFileSync('optimized-common-translations.json', JSON.stringify(optimizedCommon, null, 2), 'utf8'); - fs.writeFileSync('optimized-settings-translations.json', JSON.stringify(optimizedSettings, null, 2), 'utf8'); - - console.log('\n翻译提取完成!'); - console.log('文件已保存:'); - console.log('- missing-common-translations.json: 缺失的 common 翻译'); - console.log('- missing-settings-translations.json: 缺失的 settings 翻译'); - console.log('- full-common-translations.json: 完整的 common 翻译(包含命名空间)'); - console.log('- full-settings-translations.json: 完整的 settings 翻译(包含命名空间)'); - console.log('- optimized-common-translations.json: 优化格式的 common 翻译(不含命名空间)'); - console.log('- optimized-settings-translations.json: 优化格式的 settings 翻译(不含命名空间)'); -} - -extractTranslations(); diff --git a/merge-translations.js b/merge-translations.js deleted file mode 100644 index 441ebed4..00000000 --- a/merge-translations.js +++ /dev/null @@ -1,252 +0,0 @@ -// 读取已创建的翻译文件 -const fs = require('fs'); -const path = require('path'); - -try { - const basePath = process.cwd(); - const commonPart1Path = path.join(basePath, 'common-zh-Hans.json'); - const commonPart2Path = path.join(basePath, 'common-zh-Hans-buttons.json'); - const fullCommonPath = path.join(basePath, 'optimized-common-translations.json'); - const fullSettingsPath = path.join(basePath, 'optimized-settings-translations.json'); - - const commonPart1 = JSON.parse(fs.readFileSync(commonPart1Path, 'utf8')); - const commonPart2 = JSON.parse(fs.readFileSync(commonPart2Path, 'utf8')); - const fullCommon = JSON.parse(fs.readFileSync(fullCommonPath, 'utf8')); - const fullSettings = JSON.parse(fs.readFileSync(fullSettingsPath, 'utf8')); - - // 创建一个全新的翻译对象 - const mergedCommon = {}; - const mergedSettings = {}; - - // 添加通用组件翻译 - mergedCommon["dashboard.title"] = "仪表盘"; - mergedCommon["dashboard.overview"] = "概览"; - mergedCommon["dashboard.projects"] = "项目"; - mergedCommon["dashboard.servers"] = "服务器"; - mergedCommon["dashboard.docker"] = "Docker"; - mergedCommon["dashboard.monitoring"] = "监控"; - mergedCommon["dashboard.settings"] = "设置"; - mergedCommon["dashboard.logout"] = "退出登录"; - mergedCommon["dashboard.profile"] = "个人资料"; - mergedCommon["dashboard.terminal"] = "终端"; - mergedCommon["dashboard.containers"] = "容器"; - mergedCommon["dashboard.images"] = "镜像"; - mergedCommon["dashboard.volumes"] = "卷"; - mergedCommon["dashboard.networks"] = "网络"; - - // 按钮翻译 - mergedCommon["button.create"] = "创建"; - mergedCommon["button.edit"] = "编辑"; - mergedCommon["button.delete"] = "删除"; - mergedCommon["button.cancel"] = "取消"; - mergedCommon["button.save"] = "保存"; - mergedCommon["button.confirm"] = "确认"; - mergedCommon["button.back"] = "返回"; - mergedCommon["button.next"] = "下一步"; - mergedCommon["button.finish"] = "完成"; - - // 状态翻译 - mergedCommon["status.running"] = "运行中"; - mergedCommon["status.stopped"] = "已停止"; - mergedCommon["status.error"] = "错误"; - mergedCommon["status.pending"] = "等待中"; - mergedCommon["status.success"] = "成功"; - mergedCommon["status.failed"] = "失败"; - - // 表单翻译 - mergedCommon["form.required"] = "必填"; - mergedCommon["form.invalid"] = "无效"; - mergedCommon["form.submit"] = "提交"; - mergedCommon["form.reset"] = "重置"; - - // 通知翻译 - mergedCommon["notification.success"] = "操作成功"; - mergedCommon["notification.error"] = "操作失败"; - mergedCommon["notification.warning"] = "警告"; - mergedCommon["notification.info"] = "信息"; - - // 时间翻译 - mergedCommon["time.now"] = "刚刚"; - mergedCommon["time.minutes"] = "分钟前"; - mergedCommon["time.hours"] = "小时前"; - mergedCommon["time.days"] = "天前"; - - // 过滤翻译 - mergedCommon["filter.all"] = "全部"; - mergedCommon["filter.active"] = "活跃"; - mergedCommon["filter.inactive"] = "不活跃"; - - // 排序翻译 - mergedCommon["sort.asc"] = "升序"; - mergedCommon["sort.desc"] = "降序"; - - // 搜索翻译 - mergedCommon["search.placeholder"] = "搜索..."; - mergedCommon["search.noResults"] = "无结果"; - - // 分页翻译 - mergedCommon["pagination.prev"] = "上一页"; - mergedCommon["pagination.next"] = "下一页"; - mergedCommon["pagination.of"] = "共 {0} 页"; - - // 错误翻译 - mergedCommon["error.notFound"] = "未找到"; - mergedCommon["error.serverError"] = "服务器错误"; - mergedCommon["error.unauthorized"] = "未授权"; - mergedCommon["error.forbidden"] = "禁止访问"; - - // 通用状态翻译 - mergedCommon["loading"] = "加载中..."; - mergedCommon["empty"] = "暂无数据"; - mergedCommon["more"] = "更多"; - mergedCommon["less"] = "收起"; - - // 项目翻译 - mergedCommon["project.create"] = "创建项目"; - mergedCommon["project.edit"] = "编辑项目"; - mergedCommon["project.delete"] = "删除项目"; - mergedCommon["project.name"] = "项目名称"; - mergedCommon["project.description"] = "项目描述"; - - // 服务翻译 - mergedCommon["service.create"] = "创建服务"; - mergedCommon["service.edit"] = "编辑服务"; - mergedCommon["service.delete"] = "删除服务"; - mergedCommon["service.name"] = "服务名称"; - mergedCommon["service.type"] = "服务类型"; - - // 域名翻译 - mergedCommon["domain.add"] = "添加域名"; - mergedCommon["domain.remove"] = "移除域名"; - - // 环境变量翻译 - mergedCommon["environment.variables"] = "环境变量"; - mergedCommon["environment.add"] = "添加环境变量"; - mergedCommon["environment.edit"] = "编辑环境变量"; - mergedCommon["environment.name"] = "变量名"; - mergedCommon["environment.value"] = "变量值"; - - // 设置页面的通用翻译 - mergedSettings["common.save"] = "保存"; - mergedSettings["common.enterTerminal"] = "终端"; - - // 服务器域名设置 - mergedSettings["server.domain.title"] = "服务器域名"; - mergedSettings["server.domain.description"] = "为您的服务器应用添加域名。"; - mergedSettings["server.domain.form.domain"] = "域名"; - mergedSettings["server.domain.form.letsEncryptEmail"] = "Let's Encrypt 邮箱"; - mergedSettings["server.domain.form.certificate.label"] = "证书提供商"; - mergedSettings["server.domain.form.certificate.placeholder"] = "选择证书"; - mergedSettings["server.domain.form.certificateOptions.none"] = "无"; - mergedSettings["server.domain.form.certificateOptions.letsencrypt"] = "Let's Encrypt"; - - // Web服务器设置 - mergedSettings["server.webServer.title"] = "Web 服务器"; - mergedSettings["server.webServer.description"] = "重载或清理 Web 服务器。"; - mergedSettings["server.webServer.actions"] = "操作"; - mergedSettings["server.webServer.reload"] = "重新加载"; - mergedSettings["server.webServer.watchLogs"] = "查看日志"; - mergedSettings["server.webServer.updateServerIp"] = "更新服务器 IP"; - mergedSettings["server.webServer.server.label"] = "服务器"; - - // Traefik设置 - mergedSettings["server.webServer.traefik.label"] = "Traefik"; - mergedSettings["server.webServer.traefik.modifyEnv"] = "修改环境变量"; - mergedSettings["server.webServer.traefik.managePorts"] = "额外端口映射"; - mergedSettings["server.webServer.traefik.managePortsDescription"] = "为 Traefik 添加或删除额外端口"; - mergedSettings["server.webServer.traefik.targetPort"] = "目标端口"; - mergedSettings["server.webServer.traefik.publishedPort"] = "发布端口"; - mergedSettings["server.webServer.traefik.addPort"] = "添加端口"; - mergedSettings["server.webServer.traefik.portsUpdated"] = "端口更新成功"; - mergedSettings["server.webServer.traefik.portsUpdateError"] = "端口更新失败"; - mergedSettings["server.webServer.traefik.publishMode"] = "发布模式"; - - // 存储空间设置 - mergedSettings["server.webServer.storage.label"] = "存储空间"; - mergedSettings["server.webServer.storage.cleanUnusedImages"] = "清理未使用的镜像"; - mergedSettings["server.webServer.storage.cleanUnusedVolumes"] = "清理未使用的卷"; - mergedSettings["server.webServer.storage.cleanStoppedContainers"] = "清理已停止的容器"; - mergedSettings["server.webServer.storage.cleanDockerBuilder"] = "清理 Docker Builder 和系统"; - mergedSettings["server.webServer.storage.cleanMonitoring"] = "清理监控数据"; - mergedSettings["server.webServer.storage.cleanAll"] = "清理所有内容"; - - // 个人资料设置 - mergedSettings["profile.title"] = "账户"; - mergedSettings["profile.description"] = "在此更改您的个人资料详情。"; - mergedSettings["profile.email"] = "邮箱"; - mergedSettings["profile.password"] = "密码"; - mergedSettings["profile.avatar"] = "头像"; - - // 外观设置 - mergedSettings["appearance.title"] = "外观"; - mergedSettings["appearance.description"] = "自定义您的仪表盘主题。"; - mergedSettings["appearance.theme"] = "主题"; - mergedSettings["appearance.themeDescription"] = "为您的仪表盘选择主题"; - mergedSettings["appearance.themes.light"] = "明亮"; - mergedSettings["appearance.themes.dark"] = "暗黑"; - mergedSettings["appearance.themes.system"] = "跟随系统"; - mergedSettings["appearance.language"] = "语言"; - mergedSettings["appearance.languageDescription"] = "为您的仪表盘选择语言"; - - // 终端设置 - mergedSettings["terminal.connectionSettings"] = "连接设置"; - mergedSettings["terminal.ipAddress"] = "IP 地址"; - mergedSettings["terminal.port"] = "端口"; - mergedSettings["terminal.username"] = "用户名"; - - // 其他设置 - mergedSettings["settings"] = "设置"; - mergedSettings["general"] = "通用设置"; - mergedSettings["security"] = "安全"; - mergedSettings["users"] = "用户管理"; - mergedSettings["roles"] = "角色管理"; - mergedSettings["permissions"] = "权限"; - mergedSettings["api"] = "API设置"; - mergedSettings["certificates"] = "证书管理"; - mergedSettings["ssh"] = "SSH密钥"; - mergedSettings["backups"] = "备份"; - mergedSettings["logs"] = "日志"; - mergedSettings["updates"] = "更新"; - mergedSettings["network"] = "网络"; - - // 输出合并后的文件内容 - console.log('Common translations total:', Object.keys(mergedCommon).length); - console.log('Settings translations total:', Object.keys(mergedSettings).length); - - // 保存为最终的翻译文件 - fs.writeFileSync(path.join(basePath, 'final-zh-Hans-common.json'), JSON.stringify(mergedCommon, null, 2)); - fs.writeFileSync(path.join(basePath, 'final-zh-Hans-settings.json'), JSON.stringify(mergedSettings, null, 2)); - - // 输出翻译完成的统计 - const commonKeys = Object.keys(mergedCommon); - const settingsKeys = Object.keys(mergedSettings); - console.log('最终翻译文件已保存:'); - console.log(`- 通用翻译 (${commonKeys.length} 个词条)`); - console.log(`- 设置翻译 (${settingsKeys.length} 个词条)`); - - // 创建最终放入项目中的文件(按项目结构) - const projectCommonPath = path.join(basePath, 'apps', 'dokploy', 'public', 'locales', 'zh-Hans'); - - // 确保目录存在 - if (!fs.existsSync(projectCommonPath)) { - fs.mkdirSync(projectCommonPath, { recursive: true }); - console.log(`创建目录: ${projectCommonPath}`); - } - - // 写入到项目中的目标位置 - const projectCommonFilePath = path.join(projectCommonPath, 'common.json'); - const projectSettingsFilePath = path.join(projectCommonPath, 'settings.json'); - - console.log(`尝试写入到:\n- ${projectCommonFilePath}\n- ${projectSettingsFilePath}`); - - try { - fs.writeFileSync(projectCommonFilePath, JSON.stringify(mergedCommon, null, 2)); - fs.writeFileSync(projectSettingsFilePath, JSON.stringify(mergedSettings, null, 2)); - console.log('已成功写入到项目文件夹中!'); - } catch (error) { - console.error('写入到项目文件夹失败:', error.message); - console.log('请手动将文件复制到目标位置。'); - } -} catch (error) { - console.error('错误:', error); -} From 0e1f0b42eeb07a8aa9dafff9b4af16ed27de0287 Mon Sep 17 00:00:00 2001 From: Lorenzo Migliorero Date: Mon, 7 Apr 2025 21:43:56 +0200 Subject: [PATCH 04/14] fix(gitlab): update group name label and enhance group name handling - Updated the label for the group name input field to indicate it accepts a comma-separated list. - Modified the logic for checking group name inclusion to support multiple names separated by commas. --- .../dashboard/settings/git/gitlab/add-gitlab-provider.tsx | 4 +++- .../dashboard/settings/git/gitlab/edit-gitlab-provider.tsx | 4 +++- packages/server/src/utils/providers/gitlab.ts | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/dokploy/components/dashboard/settings/git/gitlab/add-gitlab-provider.tsx b/apps/dokploy/components/dashboard/settings/git/gitlab/add-gitlab-provider.tsx index 4dd7da93..023e46ed 100644 --- a/apps/dokploy/components/dashboard/settings/git/gitlab/add-gitlab-provider.tsx +++ b/apps/dokploy/components/dashboard/settings/git/gitlab/add-gitlab-provider.tsx @@ -248,7 +248,9 @@ export const AddGitlabProvider = () => { name="groupName" render={({ field }) => ( - Group Name (Optional) + + Group Name (Optional, Comma-Separated List) + { name="groupName" render={({ field }) => ( - Group Name (Optional) + + Group Name (Optional, Comma-Separated List) + { const groupName = gitlabProvider.groupName?.toLowerCase(); if (groupName) { - return full_path.toLowerCase().includes(groupName) && kind === "group"; + const isIncluded = groupName + .split(",") + .some((name) => full_path.toLowerCase().includes(name)); + + return isIncluded && kind === "group"; } return kind === "user"; }); From 1279fac1375b043c2812c36748b1883661f81da0 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:46:14 +0000 Subject: [PATCH 05/14] [autofix.ci] apply automated fixes --- apps/dokploy/pages/dashboard/project/[projectId].tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/pages/dashboard/project/[projectId].tsx b/apps/dokploy/pages/dashboard/project/[projectId].tsx index 6c4ac4bc..728d83d1 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId].tsx @@ -365,7 +365,9 @@ const Project = ( switch (service.type) { case "application": - await applicationActions.start.mutateAsync({ applicationId: serviceId }); + await applicationActions.start.mutateAsync({ + applicationId: serviceId, + }); break; case "compose": await composeActions.start.mutateAsync({ composeId: serviceId }); @@ -410,7 +412,9 @@ const Project = ( switch (service.type) { case "application": - await applicationActions.stop.mutateAsync({ applicationId: serviceId }); + await applicationActions.stop.mutateAsync({ + applicationId: serviceId, + }); break; case "compose": await composeActions.stop.mutateAsync({ composeId: serviceId }); From 8e97c63faafa396d5b5d030ba076c5b5baf2a212 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 13 Apr 2025 03:23:00 +0000 Subject: [PATCH 06/14] [autofix.ci] apply automated fixes --- .../public/locales/zh-Hans/common.json | 154 +++++++++--------- .../public/locales/zh-Hans/settings.json | 132 +++++++-------- 2 files changed, 143 insertions(+), 143 deletions(-) diff --git a/apps/dokploy/public/locales/zh-Hans/common.json b/apps/dokploy/public/locales/zh-Hans/common.json index d8faad7d..91af07ff 100644 --- a/apps/dokploy/public/locales/zh-Hans/common.json +++ b/apps/dokploy/public/locales/zh-Hans/common.json @@ -1,78 +1,78 @@ { - "dashboard.title": "仪表盘", - "dashboard.overview": "概览", - "dashboard.projects": "项目", - "dashboard.servers": "服务器", - "dashboard.docker": "Docker", - "dashboard.monitoring": "监控", - "dashboard.settings": "设置", - "dashboard.logout": "退出登录", - "dashboard.profile": "个人资料", - "dashboard.terminal": "终端", - "dashboard.containers": "容器", - "dashboard.images": "镜像", - "dashboard.volumes": "卷", - "dashboard.networks": "网络", - "button.create": "创建", - "button.edit": "编辑", - "button.delete": "删除", - "button.cancel": "取消", - "button.save": "保存", - "button.confirm": "确认", - "button.back": "返回", - "button.next": "下一步", - "button.finish": "完成", - "status.running": "运行中", - "status.stopped": "已停止", - "status.error": "错误", - "status.pending": "等待中", - "status.success": "成功", - "status.failed": "失败", - "form.required": "必填", - "form.invalid": "无效", - "form.submit": "提交", - "form.reset": "重置", - "notification.success": "操作成功", - "notification.error": "操作失败", - "notification.warning": "警告", - "notification.info": "信息", - "time.now": "刚刚", - "time.minutes": "分钟前", - "time.hours": "小时前", - "time.days": "天前", - "filter.all": "全部", - "filter.active": "活跃", - "filter.inactive": "不活跃", - "sort.asc": "升序", - "sort.desc": "降序", - "search.placeholder": "搜索...", - "search.noResults": "无结果", - "pagination.prev": "上一页", - "pagination.next": "下一页", - "pagination.of": "共 {0} 页", - "error.notFound": "未找到", - "error.serverError": "服务器错误", - "error.unauthorized": "未授权", - "error.forbidden": "禁止访问", - "loading": "加载中...", - "empty": "暂无数据", - "more": "更多", - "less": "收起", - "project.create": "创建项目", - "project.edit": "编辑项目", - "project.delete": "删除项目", - "project.name": "项目名称", - "project.description": "项目描述", - "service.create": "创建服务", - "service.edit": "编辑服务", - "service.delete": "删除服务", - "service.name": "服务名称", - "service.type": "服务类型", - "domain.add": "添加域名", - "domain.remove": "移除域名", - "environment.variables": "环境变量", - "environment.add": "添加环境变量", - "environment.edit": "编辑环境变量", - "environment.name": "变量名", - "environment.value": "变量值" -} \ No newline at end of file + "dashboard.title": "仪表盘", + "dashboard.overview": "概览", + "dashboard.projects": "项目", + "dashboard.servers": "服务器", + "dashboard.docker": "Docker", + "dashboard.monitoring": "监控", + "dashboard.settings": "设置", + "dashboard.logout": "退出登录", + "dashboard.profile": "个人资料", + "dashboard.terminal": "终端", + "dashboard.containers": "容器", + "dashboard.images": "镜像", + "dashboard.volumes": "卷", + "dashboard.networks": "网络", + "button.create": "创建", + "button.edit": "编辑", + "button.delete": "删除", + "button.cancel": "取消", + "button.save": "保存", + "button.confirm": "确认", + "button.back": "返回", + "button.next": "下一步", + "button.finish": "完成", + "status.running": "运行中", + "status.stopped": "已停止", + "status.error": "错误", + "status.pending": "等待中", + "status.success": "成功", + "status.failed": "失败", + "form.required": "必填", + "form.invalid": "无效", + "form.submit": "提交", + "form.reset": "重置", + "notification.success": "操作成功", + "notification.error": "操作失败", + "notification.warning": "警告", + "notification.info": "信息", + "time.now": "刚刚", + "time.minutes": "分钟前", + "time.hours": "小时前", + "time.days": "天前", + "filter.all": "全部", + "filter.active": "活跃", + "filter.inactive": "不活跃", + "sort.asc": "升序", + "sort.desc": "降序", + "search.placeholder": "搜索...", + "search.noResults": "无结果", + "pagination.prev": "上一页", + "pagination.next": "下一页", + "pagination.of": "共 {0} 页", + "error.notFound": "未找到", + "error.serverError": "服务器错误", + "error.unauthorized": "未授权", + "error.forbidden": "禁止访问", + "loading": "加载中...", + "empty": "暂无数据", + "more": "更多", + "less": "收起", + "project.create": "创建项目", + "project.edit": "编辑项目", + "project.delete": "删除项目", + "project.name": "项目名称", + "project.description": "项目描述", + "service.create": "创建服务", + "service.edit": "编辑服务", + "service.delete": "删除服务", + "service.name": "服务名称", + "service.type": "服务类型", + "domain.add": "添加域名", + "domain.remove": "移除域名", + "environment.variables": "环境变量", + "environment.add": "添加环境变量", + "environment.edit": "编辑环境变量", + "environment.name": "变量名", + "environment.value": "变量值" +} diff --git a/apps/dokploy/public/locales/zh-Hans/settings.json b/apps/dokploy/public/locales/zh-Hans/settings.json index 06033238..d70676d6 100644 --- a/apps/dokploy/public/locales/zh-Hans/settings.json +++ b/apps/dokploy/public/locales/zh-Hans/settings.json @@ -1,67 +1,67 @@ { - "settings.common.save": "保存", - "settings.common.enterTerminal": "终端", - "settings.server.domain.title": "服务器域名", - "settings.server.domain.description": "为您的服务器应用添加域名。", - "settings.server.domain.form.domain": "域名", - "settings.server.domain.form.letsEncryptEmail": "Let's Encrypt 邮箱", - "settings.server.domain.form.certificate.label": "证书提供商", - "settings.server.domain.form.certificate.placeholder": "选择证书", - "settings.server.domain.form.certificateOptions.none": "无", - "settings.server.domain.form.certificateOptions.letsencrypt": "Let's Encrypt", - "settings.server.webServer.title": "Web 服务器", - "settings.server.webServer.description": "重载或清理 Web 服务器。", - "settings.server.webServer.actions": "操作", - "settings.server.webServer.reload": "重新加载", - "settings.server.webServer.watchLogs": "查看日志", - "settings.server.webServer.updateServerIp": "更新服务器 IP", - "settings.server.webServer.server.label": "服务器", - "settings.server.webServer.traefik.label": "Traefik", - "settings.server.webServer.traefik.modifyEnv": "修改环境变量", - "settings.server.webServer.traefik.managePorts": "额外端口映射", - "settings.server.webServer.traefik.managePortsDescription": "为 Traefik 添加或删除额外端口", - "settings.server.webServer.traefik.targetPort": "目标端口", - "settings.server.webServer.traefik.publishedPort": "发布端口", - "settings.server.webServer.traefik.addPort": "添加端口", - "settings.server.webServer.traefik.portsUpdated": "端口更新成功", - "settings.server.webServer.traefik.portsUpdateError": "端口更新失败", - "settings.server.webServer.traefik.publishMode": "发布模式", - "settings.server.webServer.storage.label": "存储空间", - "settings.server.webServer.storage.cleanUnusedImages": "清理未使用的镜像", - "settings.server.webServer.storage.cleanUnusedVolumes": "清理未使用的卷", - "settings.server.webServer.storage.cleanStoppedContainers": "清理已停止的容器", - "settings.server.webServer.storage.cleanDockerBuilder": "清理 Docker Builder 和系统", - "settings.server.webServer.storage.cleanMonitoring": "清理监控数据", - "settings.server.webServer.storage.cleanAll": "清理所有内容", - "settings.profile.title": "账户", - "settings.profile.description": "在此更改您的个人资料详情。", - "settings.profile.email": "邮箱", - "settings.profile.password": "密码", - "settings.profile.avatar": "头像", - "settings.appearance.title": "外观", - "settings.appearance.description": "自定义您的仪表盘主题。", - "settings.appearance.theme": "主题", - "settings.appearance.themeDescription": "为您的仪表盘选择主题", - "settings.appearance.themes.light": "明亮", - "settings.appearance.themes.dark": "暗黑", - "settings.appearance.themes.system": "跟随系统", - "settings.appearance.language": "语言", - "settings.appearance.languageDescription": "为您的仪表盘选择语言", - "settings.terminal.connectionSettings": "连接设置", - "settings.terminal.ipAddress": "IP 地址", - "settings.terminal.port": "端口", - "settings.terminal.username": "用户名", - "settings.settings": "设置", - "settings.general": "通用设置", - "settings.security": "安全", - "settings.users": "用户管理", - "settings.roles": "角色管理", - "settings.permissions": "权限", - "settings.api": "API设置", - "settings.certificates": "证书管理", - "settings.ssh": "SSH密钥", - "settings.backups": "备份", - "settings.logs": "日志", - "settings.updates": "更新", - "settings.network": "网络" -} \ No newline at end of file + "settings.common.save": "保存", + "settings.common.enterTerminal": "终端", + "settings.server.domain.title": "服务器域名", + "settings.server.domain.description": "为您的服务器应用添加域名。", + "settings.server.domain.form.domain": "域名", + "settings.server.domain.form.letsEncryptEmail": "Let's Encrypt 邮箱", + "settings.server.domain.form.certificate.label": "证书提供商", + "settings.server.domain.form.certificate.placeholder": "选择证书", + "settings.server.domain.form.certificateOptions.none": "无", + "settings.server.domain.form.certificateOptions.letsencrypt": "Let's Encrypt", + "settings.server.webServer.title": "Web 服务器", + "settings.server.webServer.description": "重载或清理 Web 服务器。", + "settings.server.webServer.actions": "操作", + "settings.server.webServer.reload": "重新加载", + "settings.server.webServer.watchLogs": "查看日志", + "settings.server.webServer.updateServerIp": "更新服务器 IP", + "settings.server.webServer.server.label": "服务器", + "settings.server.webServer.traefik.label": "Traefik", + "settings.server.webServer.traefik.modifyEnv": "修改环境变量", + "settings.server.webServer.traefik.managePorts": "额外端口映射", + "settings.server.webServer.traefik.managePortsDescription": "为 Traefik 添加或删除额外端口", + "settings.server.webServer.traefik.targetPort": "目标端口", + "settings.server.webServer.traefik.publishedPort": "发布端口", + "settings.server.webServer.traefik.addPort": "添加端口", + "settings.server.webServer.traefik.portsUpdated": "端口更新成功", + "settings.server.webServer.traefik.portsUpdateError": "端口更新失败", + "settings.server.webServer.traefik.publishMode": "发布模式", + "settings.server.webServer.storage.label": "存储空间", + "settings.server.webServer.storage.cleanUnusedImages": "清理未使用的镜像", + "settings.server.webServer.storage.cleanUnusedVolumes": "清理未使用的卷", + "settings.server.webServer.storage.cleanStoppedContainers": "清理已停止的容器", + "settings.server.webServer.storage.cleanDockerBuilder": "清理 Docker Builder 和系统", + "settings.server.webServer.storage.cleanMonitoring": "清理监控数据", + "settings.server.webServer.storage.cleanAll": "清理所有内容", + "settings.profile.title": "账户", + "settings.profile.description": "在此更改您的个人资料详情。", + "settings.profile.email": "邮箱", + "settings.profile.password": "密码", + "settings.profile.avatar": "头像", + "settings.appearance.title": "外观", + "settings.appearance.description": "自定义您的仪表盘主题。", + "settings.appearance.theme": "主题", + "settings.appearance.themeDescription": "为您的仪表盘选择主题", + "settings.appearance.themes.light": "明亮", + "settings.appearance.themes.dark": "暗黑", + "settings.appearance.themes.system": "跟随系统", + "settings.appearance.language": "语言", + "settings.appearance.languageDescription": "为您的仪表盘选择语言", + "settings.terminal.connectionSettings": "连接设置", + "settings.terminal.ipAddress": "IP 地址", + "settings.terminal.port": "端口", + "settings.terminal.username": "用户名", + "settings.settings": "设置", + "settings.general": "通用设置", + "settings.security": "安全", + "settings.users": "用户管理", + "settings.roles": "角色管理", + "settings.permissions": "权限", + "settings.api": "API设置", + "settings.certificates": "证书管理", + "settings.ssh": "SSH密钥", + "settings.backups": "备份", + "settings.logs": "日志", + "settings.updates": "更新", + "settings.network": "网络" +} From 3d42bfc81b972e3c45adf37862c03bd089a3ef0a Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 13 Apr 2025 20:30:31 -0600 Subject: [PATCH 07/14] feat: implement debounced search functionality in RestoreBackup component - Added a new state for debounced search term to improve search performance. - Updated search handling to use the debounced value when querying backup files. - Modified the search input to reflect the current search value and handle changes accordingly. --- .../dashboard/database/backups/restore-backup.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/dokploy/components/dashboard/database/backups/restore-backup.tsx b/apps/dokploy/components/dashboard/database/backups/restore-backup.tsx index 10ebbe08..797e1ca8 100644 --- a/apps/dokploy/components/dashboard/database/backups/restore-backup.tsx +++ b/apps/dokploy/components/dashboard/database/backups/restore-backup.tsx @@ -84,6 +84,7 @@ export const RestoreBackup = ({ }: Props) => { const [isOpen, setIsOpen] = useState(false); const [search, setSearch] = useState(""); + const [debouncedSearchTerm, setDebouncedSearchTerm] = useState(""); const { data: destinations = [] } = api.destination.all.useQuery(); @@ -99,13 +100,18 @@ export const RestoreBackup = ({ const destionationId = form.watch("destinationId"); const debouncedSetSearch = debounce((value: string) => { + setDebouncedSearchTerm(value); + }, 150); + + const handleSearchChange = (value: string) => { setSearch(value); - }, 300); + debouncedSetSearch(value); + }; const { data: files = [], isLoading } = api.backup.listBackupFiles.useQuery( { destinationId: destionationId, - search, + search: debouncedSearchTerm, serverId: serverId ?? "", }, { @@ -284,7 +290,8 @@ export const RestoreBackup = ({ {isLoading ? ( @@ -308,6 +315,8 @@ export const RestoreBackup = ({ key={file} onSelect={() => { form.setValue("backupFile", file); + setSearch(file); + setDebouncedSearchTerm(file); }} >
From 850d06a32c876369ad5a8c4336f3f6ace92de712 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 13 Apr 2025 21:59:36 -0600 Subject: [PATCH 08/14] chore: bump version to v0.21.7 in package.json --- apps/dokploy/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dokploy/package.json b/apps/dokploy/package.json index 7a8cc891..7836ff30 100644 --- a/apps/dokploy/package.json +++ b/apps/dokploy/package.json @@ -1,6 +1,6 @@ { "name": "dokploy", - "version": "v0.21.6", + "version": "v0.21.7", "private": true, "license": "Apache-2.0", "type": "module", From dbd36fc024215e236aaa39bebe5db1dbfe85a122 Mon Sep 17 00:00:00 2001 From: Axodouble Date: Mon, 14 Apr 2025 08:42:30 +0200 Subject: [PATCH 09/14] Fix for #1708, missing dutch translation and sorted list by population --- apps/dokploy/lib/languages.ts | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/dokploy/lib/languages.ts b/apps/dokploy/lib/languages.ts index a19c9589..7a4d54fa 100644 --- a/apps/dokploy/lib/languages.ts +++ b/apps/dokploy/lib/languages.ts @@ -1,23 +1,27 @@ +/** + * Sorted list based off of population of the country / speakers of the language. + */ export const Languages = { english: { code: "en", name: "English" }, + spanish: { code: "es", name: "Español" }, + chineseSimplified: { code: "zh-Hans", name: "简体中文" }, + chineseTraditional: { code: "zh-Hant", name: "繁體中文" }, + portuguese: { code: "pt-br", name: "Português" }, + russian: { code: "ru", name: "Русский" }, + japanese: { code: "ja", name: "日本語" }, + german: { code: "de", name: "Deutsch" }, + korean: { code: "ko", name: "한국어" }, + french: { code: "fr", name: "Français" }, + turkish: { code: "tr", name: "Türkçe" }, + italian: { code: "it", name: "Italiano" }, polish: { code: "pl", name: "Polski" }, ukrainian: { code: "uk", name: "Українська" }, - russian: { code: "ru", name: "Русский" }, - french: { code: "fr", name: "Français" }, - german: { code: "de", name: "Deutsch" }, - chineseTraditional: { code: "zh-Hant", name: "繁體中文" }, - chineseSimplified: { code: "zh-Hans", name: "简体中文" }, - turkish: { code: "tr", name: "Türkçe" }, - kazakh: { code: "kz", name: "Қазақ" }, persian: { code: "fa", name: "فارسی" }, - korean: { code: "ko", name: "한국어" }, - portuguese: { code: "pt-br", name: "Português" }, - italian: { code: "it", name: "Italiano" }, - japanese: { code: "ja", name: "日本語" }, - spanish: { code: "es", name: "Español" }, + dutch: { code: "nl", name: "Nederlands" }, + indonesian: { code: "id", name: "Bahasa Indonesia" }, + kazakh: { code: "kz", name: "Қазақ" }, norwegian: { code: "no", name: "Norsk" }, azerbaijani: { code: "az", name: "Azərbaycan" }, - indonesian: { code: "id", name: "Bahasa Indonesia" }, malayalam: { code: "ml", name: "മലയാളം" }, }; From f4054453b42a1ba804cbb791c187dd2d41de7387 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 06:46:16 +0000 Subject: [PATCH 10/14] [autofix.ci] apply automated fixes --- apps/dokploy/public/locales/nl/common.json | 2 +- apps/dokploy/public/locales/nl/settings.json | 116 +++++++++---------- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/apps/dokploy/public/locales/nl/common.json b/apps/dokploy/public/locales/nl/common.json index 69a88e3b..0967ef42 100644 --- a/apps/dokploy/public/locales/nl/common.json +++ b/apps/dokploy/public/locales/nl/common.json @@ -1 +1 @@ -{} +{} diff --git a/apps/dokploy/public/locales/nl/settings.json b/apps/dokploy/public/locales/nl/settings.json index 34c492ec..c76d9bb9 100644 --- a/apps/dokploy/public/locales/nl/settings.json +++ b/apps/dokploy/public/locales/nl/settings.json @@ -1,58 +1,58 @@ -{ - "settings.common.save": "Opslaan", - "settings.common.enterTerminal": "Terminal", - "settings.server.domain.title": "Server Domein", - "settings.server.domain.description": "Voeg een domein toe aan jouw server applicatie.", - "settings.server.domain.form.domain": "Domein", - "settings.server.domain.form.letsEncryptEmail": "Let's Encrypt Email", - "settings.server.domain.form.certificate.label": "Certificaat Aanbieder", - "settings.server.domain.form.certificate.placeholder": "Select een certificaat", - "settings.server.domain.form.certificateOptions.none": "Geen", - "settings.server.domain.form.certificateOptions.letsencrypt": "Let's Encrypt", - - "settings.server.webServer.title": "Web Server", - "settings.server.webServer.description": "Herlaad of maak de web server schoon.", - "settings.server.webServer.actions": "Acties", - "settings.server.webServer.reload": "Herladen", - "settings.server.webServer.watchLogs": "Bekijk Logs", - "settings.server.webServer.updateServerIp": "Update de Server IP", - "settings.server.webServer.server.label": "Server", - "settings.server.webServer.traefik.label": "Traefik", - "settings.server.webServer.traefik.modifyEnv": "Bewerk Omgeving", - "settings.server.webServer.traefik.managePorts": "Extra Poort Mappings", - "settings.server.webServer.traefik.managePortsDescription": "Bewerk extra Poorten voor Traefik", - "settings.server.webServer.traefik.targetPort": "Doel Poort", - "settings.server.webServer.traefik.publishedPort": "Gepubliceerde Poort", - "settings.server.webServer.traefik.addPort": "Voeg Poort toe", - "settings.server.webServer.traefik.portsUpdated": "Poorten succesvol aangepast", - "settings.server.webServer.traefik.portsUpdateError": "Poorten niet succesvol aangepast", - "settings.server.webServer.traefik.publishMode": "Publiceer Mode", - "settings.server.webServer.storage.label": "Opslag", - "settings.server.webServer.storage.cleanUnusedImages": "Maak ongebruikte images schoon", - "settings.server.webServer.storage.cleanUnusedVolumes": "Maak ongebruikte volumes schoon", - "settings.server.webServer.storage.cleanStoppedContainers": "Maak gestopte containers schoon", - "settings.server.webServer.storage.cleanDockerBuilder": "Maak Docker Builder & Systeem schoon", - "settings.server.webServer.storage.cleanMonitoring": "Maak monitoor schoon", - "settings.server.webServer.storage.cleanAll": "Maak alles schoon", - - "settings.profile.title": "Account", - "settings.profile.description": "Veramder details van account.", - "settings.profile.email": "Email", - "settings.profile.password": "Wachtwoord", - "settings.profile.avatar": "Profiel Icoon", - - "settings.appearance.title": "Uiterlijk", - "settings.appearance.description": "Verander het thema van je dashboard.", - "settings.appearance.theme": "Thema", - "settings.appearance.themeDescription": "Selecteer een thema voor je dashboard.", - "settings.appearance.themes.light": "Licht", - "settings.appearance.themes.dark": "Donker", - "settings.appearance.themes.system": "Systeem", - "settings.appearance.language": "Taal", - "settings.appearance.languageDescription": "Selecteer een taal voor je dashboard.", - - "settings.terminal.connectionSettings": "Verbindings instellingen", - "settings.terminal.ipAddress": "IP Address", - "settings.terminal.port": "Poort", - "settings.terminal.username": "Gebruikersnaam" -} +{ + "settings.common.save": "Opslaan", + "settings.common.enterTerminal": "Terminal", + "settings.server.domain.title": "Server Domein", + "settings.server.domain.description": "Voeg een domein toe aan jouw server applicatie.", + "settings.server.domain.form.domain": "Domein", + "settings.server.domain.form.letsEncryptEmail": "Let's Encrypt Email", + "settings.server.domain.form.certificate.label": "Certificaat Aanbieder", + "settings.server.domain.form.certificate.placeholder": "Select een certificaat", + "settings.server.domain.form.certificateOptions.none": "Geen", + "settings.server.domain.form.certificateOptions.letsencrypt": "Let's Encrypt", + + "settings.server.webServer.title": "Web Server", + "settings.server.webServer.description": "Herlaad of maak de web server schoon.", + "settings.server.webServer.actions": "Acties", + "settings.server.webServer.reload": "Herladen", + "settings.server.webServer.watchLogs": "Bekijk Logs", + "settings.server.webServer.updateServerIp": "Update de Server IP", + "settings.server.webServer.server.label": "Server", + "settings.server.webServer.traefik.label": "Traefik", + "settings.server.webServer.traefik.modifyEnv": "Bewerk Omgeving", + "settings.server.webServer.traefik.managePorts": "Extra Poort Mappings", + "settings.server.webServer.traefik.managePortsDescription": "Bewerk extra Poorten voor Traefik", + "settings.server.webServer.traefik.targetPort": "Doel Poort", + "settings.server.webServer.traefik.publishedPort": "Gepubliceerde Poort", + "settings.server.webServer.traefik.addPort": "Voeg Poort toe", + "settings.server.webServer.traefik.portsUpdated": "Poorten succesvol aangepast", + "settings.server.webServer.traefik.portsUpdateError": "Poorten niet succesvol aangepast", + "settings.server.webServer.traefik.publishMode": "Publiceer Mode", + "settings.server.webServer.storage.label": "Opslag", + "settings.server.webServer.storage.cleanUnusedImages": "Maak ongebruikte images schoon", + "settings.server.webServer.storage.cleanUnusedVolumes": "Maak ongebruikte volumes schoon", + "settings.server.webServer.storage.cleanStoppedContainers": "Maak gestopte containers schoon", + "settings.server.webServer.storage.cleanDockerBuilder": "Maak Docker Builder & Systeem schoon", + "settings.server.webServer.storage.cleanMonitoring": "Maak monitoor schoon", + "settings.server.webServer.storage.cleanAll": "Maak alles schoon", + + "settings.profile.title": "Account", + "settings.profile.description": "Veramder details van account.", + "settings.profile.email": "Email", + "settings.profile.password": "Wachtwoord", + "settings.profile.avatar": "Profiel Icoon", + + "settings.appearance.title": "Uiterlijk", + "settings.appearance.description": "Verander het thema van je dashboard.", + "settings.appearance.theme": "Thema", + "settings.appearance.themeDescription": "Selecteer een thema voor je dashboard.", + "settings.appearance.themes.light": "Licht", + "settings.appearance.themes.dark": "Donker", + "settings.appearance.themes.system": "Systeem", + "settings.appearance.language": "Taal", + "settings.appearance.languageDescription": "Selecteer een taal voor je dashboard.", + + "settings.terminal.connectionSettings": "Verbindings instellingen", + "settings.terminal.ipAddress": "IP Address", + "settings.terminal.port": "Poort", + "settings.terminal.username": "Gebruikersnaam" +} From bdc10cacef6ef4a5d48de8c4c33dbdb1126f9d71 Mon Sep 17 00:00:00 2001 From: unleashit Date: Tue, 15 Apr 2025 14:38:37 -0700 Subject: [PATCH 11/14] docs(contributing): recommendations to use biome IDE addons and nvm for node version - emphasis added since using later versions of Node cause errors in the terminal - since the project uses biome but most IDEs have eslint/prettier addons, this tip will avoid commit/build suprises --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 015095aa..52fd7f2f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,7 +52,7 @@ feat: add new feature Before you start, please make the clone based on the `canary` branch, since the `main` branch is the source of truth and should always reflect the latest stable release, also the PRs will be merged to the `canary` branch. -We use Node v20.9.0 +We use Node v20.9.0 and recommend this specific version. If you have nvm installed, you can run `nvm install 20.9.0 && nvm use` in the root directory. ```bash git clone https://github.com/dokploy/dokploy.git @@ -87,6 +87,8 @@ pnpm run dokploy:dev Go to http://localhost:3000 to see the development server +Note: this project uses Biome. If your editor is configured to use another formatter such as Prettier, it's recommended to either change it to use Biome or turn it off. + ## Build ```bash From 48cfe66a6b8d1519ce43abfd9138ad7ed888f4f4 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 17 Apr 2025 00:25:27 -0600 Subject: [PATCH 12/14] Refactor 2FA enablement flow in Enable2FA component - Simplified the password submission and verification processes. - Introduced a new state for OTP input, allowing for direct user input. - Updated error handling to provide clearer feedback during the verification process. - Enhanced the user experience by resetting the OTP value when switching steps and modifying the form structure for better clarity. --- .../dashboard/settings/profile/enable-2fa.tsx | 198 +++++++++--------- 1 file changed, 98 insertions(+), 100 deletions(-) diff --git a/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx b/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx index 1cfa7574..afc859f4 100644 --- a/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx +++ b/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx @@ -61,6 +61,79 @@ export const Enable2FA = () => { const [isDialogOpen, setIsDialogOpen] = useState(false); const [step, setStep] = useState<"password" | "verify">("password"); const [isPasswordLoading, setIsPasswordLoading] = useState(false); + const [otpValue, setOtpValue] = useState(""); + + const handleVerifySubmit = async (e: React.FormEvent) => { + e.preventDefault(); + try { + const result = await authClient.twoFactor.verifyTotp({ + code: otpValue, + }); + + if (result.error) { + if (result.error.code === "INVALID_TWO_FACTOR_AUTHENTICATION") { + toast.error("Invalid verification code"); + return; + } + + throw result.error; + } + + if (!result.data) { + throw new Error("No response received from server"); + } + + toast.success("2FA configured successfully"); + utils.user.get.invalidate(); + setIsDialogOpen(false); + } catch (error) { + if (error instanceof Error) { + const errorMessage = + error.message === "Failed to fetch" + ? "Connection error. Please check your internet connection." + : error.message; + + toast.error(errorMessage); + } else { + toast.error("Error verifying 2FA code", { + description: error instanceof Error ? error.message : "Unknown error", + }); + } + } + }; + + const passwordForm = useForm({ + resolver: zodResolver(PasswordSchema), + defaultValues: { + password: "", + }, + }); + + const pinForm = useForm({ + resolver: zodResolver(PinSchema), + defaultValues: { + pin: "", + }, + }); + + useEffect(() => { + if (!isDialogOpen) { + setStep("password"); + setData(null); + setBackupCodes([]); + setOtpValue(""); + passwordForm.reset({ + password: "", + issuer: "", + }); + } + }, [isDialogOpen, passwordForm]); + + useEffect(() => { + if (step === "verify") { + setOtpValue(""); + } + }, [step]); const handlePasswordSubmit = async (formData: PasswordForm) => { setIsPasswordLoading(true); @@ -105,75 +178,6 @@ export const Enable2FA = () => { } }; - const handleVerifySubmit = async (formData: PinForm) => { - try { - const result = await authClient.twoFactor.verifyTotp({ - code: formData.pin, - }); - - if (result.error) { - if (result.error.code === "INVALID_TWO_FACTOR_AUTHENTICATION") { - pinForm.setError("pin", { - message: "Invalid code. Please try again.", - }); - toast.error("Invalid verification code"); - return; - } - - throw result.error; - } - - if (!result.data) { - throw new Error("No response received from server"); - } - - toast.success("2FA configured successfully"); - utils.user.get.invalidate(); - setIsDialogOpen(false); - } catch (error) { - if (error instanceof Error) { - const errorMessage = - error.message === "Failed to fetch" - ? "Connection error. Please check your internet connection." - : error.message; - - pinForm.setError("pin", { - message: errorMessage, - }); - toast.error(errorMessage); - } else { - pinForm.setError("pin", { - message: "Error verifying code", - }); - toast.error("Error verifying 2FA code"); - } - } - }; - - const passwordForm = useForm({ - resolver: zodResolver(PasswordSchema), - defaultValues: { - password: "", - }, - }); - - const pinForm = useForm({ - resolver: zodResolver(PinSchema), - defaultValues: { - pin: "", - }, - }); - - useEffect(() => { - if (!isDialogOpen) { - setStep("password"); - setData(null); - setBackupCodes([]); - passwordForm.reset(); - pinForm.reset(); - } - }, [isDialogOpen, passwordForm, pinForm]); - return ( @@ -233,7 +237,8 @@ export const Enable2FA = () => { /> - Enter your password to enable 2FA + Use a custom issuer to identify the service you're + authenticating with. @@ -250,11 +255,7 @@ export const Enable2FA = () => { ) : (
- +
{data?.qrCodeUrl ? ( <> @@ -306,36 +307,33 @@ export const Enable2FA = () => { )}
- ( - - Verification Code - - - - - - - - - - - - - - Enter the 6-digit code from your authenticator app - - - - )} - /> +
+ Verification Code + + + + + + + + + + + + Enter the 6-digit code from your authenticator app + +
From 8e8bc3e71e3c836dce085bc370be933b47bf570f Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 17 Apr 2025 01:58:25 -0600 Subject: [PATCH 13/14] Enhance PostgreSQL backup command in web server utility - Added error handling to check for the existence of the PostgreSQL container before executing the backup command. - Updated the backup command to use the retrieved container ID, ensuring the command runs correctly. --- packages/server/src/utils/backups/web-server.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utils/backups/web-server.ts b/packages/server/src/utils/backups/web-server.ts index a7d48a2f..ef2249d0 100644 --- a/packages/server/src/utils/backups/web-server.ts +++ b/packages/server/src/utils/backups/web-server.ts @@ -23,7 +23,17 @@ export const runWebServerBackup = async (backup: BackupSchedule) => { try { await execAsync(`mkdir -p ${tempDir}/filesystem`); - const postgresCommand = `docker exec $(docker ps --filter "name=dokploy-postgres" -q) pg_dump -v -Fc -U dokploy -d dokploy > ${tempDir}/database.sql`; + // First get the container ID + const { stdout: containerId } = await execAsync( + "docker ps --filter 'name=dokploy-postgres' -q", + ); + + if (!containerId) { + throw new Error("PostgreSQL container not found"); + } + + // Then run pg_dump with the container ID + const postgresCommand = `docker exec ${containerId.trim()} pg_dump -v -Fc -U dokploy -d dokploy > '${tempDir}/database.sql'`; await execAsync(postgresCommand); await execAsync(`cp -r ${BASE_PATH}/* ${tempDir}/filesystem/`); From 33ab87f3db3dea19362ba1f2bc9e6fa1d8288c97 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 17 Apr 2025 02:20:03 -0600 Subject: [PATCH 14/14] fix(gitlab): enhance group name matching logic to support multiple names - Updated the group name check to allow for a comma-separated list of names, improving flexibility in group name validation. --- packages/server/src/utils/providers/gitlab.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utils/providers/gitlab.ts b/packages/server/src/utils/providers/gitlab.ts index b8a58fd8..d01cc400 100644 --- a/packages/server/src/utils/providers/gitlab.ts +++ b/packages/server/src/utils/providers/gitlab.ts @@ -435,7 +435,9 @@ export const testGitlabConnection = async ( const { full_path, kind } = repo.namespace; if (groupName) { - return full_path.toLowerCase().includes(groupName) && kind === "group"; + return groupName + .split(",") + .some((name) => full_path.toLowerCase().includes(name)); } return kind === "user"; });