-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Refine English translation #8991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bfc9716
68217dd
96a8938
9452ec1
c31ba75
1a3dbad
cdee9e7
94b999c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import * as echarts from 'echarts'; | |
| import { GlobalStore } from '@/store'; | ||
| import { computeSizeFromKBs, computeSizeFromKB, computeSizeFromMB } from '@/utils/util'; | ||
| import { storeToRefs } from 'pinia'; | ||
| import i18n from '@/lang'; | ||
| const globalStore = GlobalStore(); | ||
| const { isDarkTheme } = storeToRefs(globalStore); | ||
|
|
||
|
|
@@ -153,17 +154,35 @@ function initChart() { | |
| switch (props.option.formatStr) { | ||
| case 'KB/s': | ||
| for (const item of datas) { | ||
| res += item.marker + ' ' + item.seriesName + ':' + computeSizeFromKBs(item.data) + '<br/>'; | ||
| res += | ||
| item.marker + | ||
| ' ' + | ||
| item.seriesName + | ||
| i18n.global.t('commons.colon') + | ||
| computeSizeFromKBs(item.data) + | ||
| '<br/>'; | ||
| } | ||
| break; | ||
| case 'KB': | ||
| for (const item of datas) { | ||
| res += item.marker + ' ' + item.seriesName + ':' + computeSizeFromKB(item.data) + '<br/>'; | ||
| res += | ||
| item.marker + | ||
| ' ' + | ||
| item.seriesName + | ||
| i18n.global.t('commons.colon') + | ||
| computeSizeFromKB(item.data) + | ||
| '<br/>'; | ||
| } | ||
| break; | ||
| case 'MB': | ||
| for (const item of datas) { | ||
| res += item.marker + ' ' + item.seriesName + ':' + computeSizeFromMB(item.data) + '<br/>'; | ||
| res += | ||
| item.marker + | ||
| ' ' + | ||
| item.seriesName + | ||
| i18n.global.t('commons.colon') + | ||
| computeSizeFromMB(item.data) + | ||
| '<br/>'; | ||
| } | ||
| break; | ||
| default: | ||
|
|
@@ -172,7 +191,7 @@ function initChart() { | |
| item.marker + | ||
| ' ' + | ||
| item.seriesName + | ||
| ':' + | ||
| i18n.global.t('commons.colon') + | ||
| item.data + | ||
| props.option.formatStr + | ||
| '<br/>'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code you provided has several minor improvements that can be made:
Here's an optimized version of the function initChart() {
let res = '';
switch (props.option.formatStr) {
case 'KB/s':
for (const item of datas) {
const size = computeSizeFromKBs(item.data);
res += `${item.marker} ${item.seriesName}${i18n.global.t('commons.colon')} ${size}<br>`;
}
break;
case 'KB':
for (const item of datas) {
const size = computeSizeFromKB(item.data);
res += `${item.marker} ${item.seriesName}${i18n.global.t('commons.colon')} ${size}<br>`;
}
break;
case 'MB':
for (const item of datas) {
const size = computeSizeFromMB(item.data);
res += `${item.marker} ${item.seriesName}${i18n.global.t('commons.colon')} ${size}<br>`;
}
break;
default:
// Handle other cases if needed
break;
}
return re;
}Additionally, consider implementing a helper function to handle the formatting in a more modular way: import { computeSizeFromKBs, computeSizeFromKB, computeSizeFromMB } from '@/utils/util';
function formatSize(size, formatStr, isDarkTheme) {
const postfixes = ['KB/s', 'KB', 'MB'].includes(formatStr)
? ['B/s', 'B', 'MB']
: ['MB/s'];
return size.toString() + postfixes[postfixes.indexOf(formatStr)];
}
// Usage within initChart
let res = '';
switch (props.option.formatStr) {
case 'KB/s':
for (const item of datas) {
const formattedValue = formatSize(computeSizeFromKBs(item.data), 'KB/s', isDarkTheme);
res += `${item.marker} ${item.seriesName}: ${formattedValue}<br>`;
}
break;
case 'KB':
for (const item of datas) {
const formattedValue = formatSize(computeSizeFromKB(item.data), 'KB', isDarkTheme);
res += `${item.marker} ${item.seriesName}: ${formattedValue}<br>`;
}
break;
case 'MB':
for (const item of datas) {
const formattedValue = formatSize(computeSizeFromMB(item.data), 'MB', isDarkTheme);
res += `${item.marker} ${item.seriesName}: ${formattedValue}<br>`;
}
break;
default:
// Handle other cases if needed
break;
}
return res;This approach makes the code cleaner and easier to maintain, especially when adding support for additional units or adjusting formats dynamically.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code makes several changes that are intended to improve clarity and maintainability. Here’s a brief summary of the key points:
These changes enhance code quality by making it more readable and easier to test across different languages. Overall, these modifications align well with good coding practices and will ensure that the application is robust and maintainable in the long run. |
||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,10 @@ const message = { | |
| commons: { | ||
| true: '是', | ||
| false: '否', | ||
| colon: ':', | ||
| example: '例:', | ||
| fit2cloud: '飞致云', | ||
| lingxia: '凌霞', | ||
| colon: ': ', | ||
| button: { | ||
| run: '运行', | ||
| prev: '上一步', | ||
|
|
@@ -126,8 +126,8 @@ const message = { | |
| protocol: '协议', | ||
| tableSetting: '列表设置', | ||
| refreshRate: '刷新频率', | ||
| noRefresh: '不刷新', | ||
| selectColumn: '选择列', | ||
| noRefresh: '不刷新', | ||
| local: '本地', | ||
| serialNumber: '序号', | ||
| }, | ||
|
|
@@ -444,7 +444,7 @@ const message = { | |
| loadBackup: '导入备份', | ||
| remoteAccess: '远程访问', | ||
| remoteHelper: '多个 ip 以逗号分隔,例:172.16.10.111,172.16.10.112', | ||
| remoteConnHelper: 'root 帐号远程连接 mysql 有安全风险,开启需谨慎!', | ||
| remoteConnHelper: 'root 帐号远程连接 MySQL 有安全风险,开启需谨慎!', | ||
| changePassword: '改密', | ||
| changeConnHelper: '此操作将修改当前数据库 {0},是否继续?', | ||
| changePasswordHelper: '当前数据库已经关联应用,修改密码将同步修改应用中数据库密码,修改后重启生效。', | ||
|
|
@@ -462,6 +462,7 @@ const message = { | |
| passwordHelper: '无法获取密码,请修改', | ||
| remote: '远程', | ||
| remoteDB: '远程服务器', | ||
| manageRemoteDB: '管理远程服务器', | ||
| createRemoteDB: '添加远程服务器', | ||
| unBindRemoteDB: '解绑远程服务器', | ||
| unBindForce: '强制解绑', | ||
|
|
@@ -938,6 +939,7 @@ const message = { | |
| taskType: '任务类型', | ||
| nextTime: '近 5 次执行', | ||
| record: '报告', | ||
| viewRecords: '查看报告', | ||
| shell: 'Shell 脚本', | ||
| log: '备份日志', | ||
| logHelper: '备份系统日志', | ||
|
|
@@ -1201,6 +1203,7 @@ const message = { | |
| 'ClamAV 的最低建议配置为:3 GiB 以上的 RAM,2.0 GHz 以上的单核 CPU,以及至少 5 GiB 的可用硬盘空间', | ||
| notStart: '当前未开启 ClamAV 服务,请先开启!', | ||
| removeRecord: '删除报告文件', | ||
| noRecords: '点击“执行”按钮开始扫描,扫描结果将会记录在这里。', | ||
| removeResultHelper: '删除任务执行过程中生成的报告文件,以清理存储空间。', | ||
| removeInfected: '删除病毒文件', | ||
| removeInfectedHelper: '删除任务检测到的病毒文件,以确保服务器的安全和正常运行。', | ||
|
|
@@ -1277,6 +1280,7 @@ const message = { | |
| fileName: '文件名', | ||
| search: '在当前目录下查找', | ||
| mode: '权限', | ||
| editPermissions: '编辑@:file.mode', | ||
| owner: '所有者', | ||
| file: '文件', | ||
| remoteFile: '远程下载', | ||
|
|
@@ -1524,12 +1528,12 @@ const message = { | |
| developerModeHelper: '获取 1Panel 的预览版本,以分享有关新功能和更新的反馈', | ||
|
|
||
| thirdParty: '第三方账号', | ||
| noTypeForCreate: '当前无可创建备份类型', | ||
| scope: '使用范围', | ||
| public: '公有', | ||
| publicHelper: '公有类型的备份账号会同步到各个子节点,子节点可以一起使用', | ||
| private: '私有', | ||
| privateHelper: '私有类型的备份账号只创建在当前节点上,仅供当前节点使用', | ||
| noTypeForCreate: '当前无可创建备份类型', | ||
| LOCAL: '服务器磁盘', | ||
| OSS: '阿里云 OSS', | ||
| S3: '亚马逊 S3 云存储', | ||
|
|
@@ -1642,6 +1646,7 @@ const message = { | |
| reRollback: '回滚快照失败', | ||
| deleteHelper: '将删除该快照的所有备份文件,包括第三方备份账号中的文件。', | ||
| ignoreRule: '排除规则', | ||
| editIgnoreRule: '@:commons.button.edit@:setting.ignoreRule', | ||
| ignoreHelper: '快照时将使用该规则对 1Panel 数据目录进行压缩备份,请谨慎修改。', | ||
| ignoreHelper1: '一行一个,例: \n*.log\n/opt/1panel/cache', | ||
| status: '快照状态', | ||
|
|
@@ -2008,7 +2013,7 @@ const message = { | |
| deleteApp: '删除应用', | ||
| deleteBackup: '删除备份', | ||
| domain: '域名', | ||
| domainHelper: '一行一个域名,支持*和IP地址,支持域名:端口', | ||
| domainHelper: '一行一个域名,支持*和IP地址,支持"域名:端口"', | ||
| addDomain: '新增域名', | ||
| domainConfig: '域名设置', | ||
| defaultDoc: '默认文档', | ||
|
|
@@ -2129,7 +2134,7 @@ const message = { | |
| websiteDeploymentHelper: '使用从 1Panel 部署的应用创建网站', | ||
| websiteStatictHelper: '在主机上创建网站目录', | ||
| websiteProxyHelper: | ||
| '代理已有服务,例如本机已安装使用 8080 端口的 halo 服务,那么代理地址为 http://127.0.0.1:8080', | ||
| '代理已有服务。例如本机已安装使用 8080 端口的 halo 服务,那么代理地址为 http://127.0.0.1:8080', | ||
| restoreHelper: '确认使用此备份恢复?', | ||
| wafValueHelper: '值', | ||
| runtimeProxyHelper: '使用从 1Panel 创建的运行环境', | ||
|
|
@@ -2161,7 +2166,7 @@ const message = { | |
| disabled: '已停止', | ||
| startProxy: '开启反向代理', | ||
| stopProxy: '关闭反向代理', | ||
| proxyFile: '源文', | ||
| sourceFile: '源文', | ||
| proxyHelper1: '访问这个目录时将会把目标URL的内容返回并显示', | ||
| proxyPassHelper: '代理的站点,必须为可正常访问的URL', | ||
| proxyHostHelper: '将域名添加到请求头传递到代理服务器', | ||
|
|
@@ -2468,8 +2473,11 @@ const message = { | |
| addressHelper2: '多个 IP 或 IP 段 请用 "," 隔开:172.16.10.11,172.16.0.0/24', | ||
| allIP: '所有 IP', | ||
| portRule: '端口规则', | ||
| createPortRule: '@:commons.button.create@:firewall.portRule', | ||
| forwardRule: '端口转发', | ||
| createForwardRule: '@:commons.button.create@:firewall.forwardRule', | ||
| ipRule: 'IP 规则', | ||
| createIpRule: '@:commons.button.create @:firewall.ipRule', | ||
| userAgent: 'User-Agent 过滤', | ||
| destination: '目的地', | ||
| sourcePort: '源端口', | ||
|
|
@@ -2578,6 +2586,7 @@ const message = { | |
| laddr: '本地地址/端口', | ||
| raddr: '远程地址/端口', | ||
| stopProcess: '结束', | ||
| viewDetails: '查看详情', | ||
| stopProcessWarn: '是否确定结束此进程 (PID:{0})?', | ||
| processName: '进程名称', | ||
| }, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code snippet appears to be editing an object Observations
Suggestions
By addressing these points, you can ensure that the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code DifferencesIrregularities and Potential Issues:
Optimization Suggestions:
Overall, these changes will help improve the readability and maintainability of the codebase, ensuring fewer errors and improving user experience through better functionality.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code snippet is for translations of messages into Chinese. However, some changes need to be made:
Suggested modifications: {
"commons": {
"true": "是",
"false": "否",
"colon": ":", // Remove duplicates
"example": "例:",
"fit2cloud": "飞致云",
"lingxia": "凌霞",
"button": {
"run": "运行",
"prev": "上一步",
"next": "下一步",
"create": "创建"
}
},
"errorCodes": { /* ... remains unchanged */ },
"messages": {
"backupAndRestore": {
"selectMethod": "请选择备份方法",
"backupPath": "本地路径",
"localDBConnectionTest": "测试本地 MySQL 连接",
"remoteConn": "远程数据库连接",
"restoreLocal": "还原本地数据库备份",
"scanFiles": "扫描文件并检查病毒"
},
"configurations": { /* ... remains unchanged except for minor grammar fixes */ },
"logs": { /* ... remains unchanged except for minor grammar fixes */ },
"tasks": { /* ... remains unchanged except for the suggested modification */ },
"users": { /* ... remains unchanged except for minor grammar fixes */ },
"settings": { /* ... remains unchanged except for the suggested modification */ },
"appsManager": { /* ... remains unchanged except for minimal adjustments */ },
"webserver": { /* ... remains unchanged except for minor grammar fixes */ },
"database": { /* ... remains unchanged except for additional translation of new options */ },
// Additional translations
"editPermissions": "编辑权限设置",
"sourceFile": "源文件",
"viewDetails": "查看详情",
// New buttons and phrases
"manageRemoteServers": "管理远程服务器",
"createRemoteServer": "添加远程服务器",
"deleteHelper": " |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code appears to be correct and functional at first glance. Here are some minor optimizations and notes:
Template Literals: You can use template literals with backticks (
) instead of concatenation with the+operator for cleaner readability.String Interpolation: Using ES6 string interpolation within the
tmethod from Vue I18n can make the code more readable and concise.Here's the optimized version using these techniques:
Key Changes:
Template Literals: Replace direct string concatenation with template literals, which makes the syntax cleaner and easier to read.
`${item.marker} ${i18n.global.t('chartSeries')}: ${computeSizeFromKBs(item.data)}`Interpolated Translation Keys: Use double quotes around template variable names for clarity. If you prefer single quotes, ensure consistency within the same code block.
These changes improve maintainability and reduce visual clutter while maintaining the functionality of the code.