-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Conversation
* Refine plural translation of English words * Remove useless i18n modifier
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
} | ||
|
||
.system-content { | ||
font-size: 13px !important; | ||
border: none !important; | ||
width: 100% !important; | ||
} | ||
|
||
.monitor-tags { |
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 provided code snippet contains a few changes that could be optimized or improved:
-
Translation Parameter: The
:$t(..)
function now takes an additional parameter to specify the index of placeholders if using array translation messages. However, this isn't utilized in this particular section. -
Inline Styles: Inline styles within
<style>
tags are not recommended for readability and maintainability. It would benefit from breaking them into individual CSS classes and applying those classes in the HTML where necessary. -
Element Classes: Using classes can make it easier to manage styling and potentially improve performance when dynamically adding/removing elements during rendering. For instance,
.system-label
should ideally apply consistent styles across all usage to avoid repetitive inline styles.
Here is how some of these points might look after refining the CSS:
<style lang="scss">
.h-overview .el-col {
span,
div.count > span {
cursor: pointer; /* Added cursor change for click events */
}
}
.el-descriptions-item.system-content {
line-height: 16px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif, "Microsoft YaHei";
& > .el-descriptions__label {
display: flex;
// Remove unnecessary padding/margin
margin-right: 8px;
&:not(:first-child)::before {
content: "• ";
position: absolute;
top: -7px; /* Adjust positioning based on needs */
}
}
&.__cell-value-wrapper .el-button-group .el-button {
padding: 2px 6px; /* Optional: reduce button size if needed */
&:not(:last-child):after {
content: "|"; /* Add separator between buttons */
margin-left: 3px; /* Optional: add space around separators if needed */
}
}
strong { font-weight: bold !important} /* Apply font weight */
p span {line-height: 18px } /* Apply specific style to child spans */
}
</style>
In summary, while there aren’t major issues with the functional aspect of the code itself, improvements such as refactoring styles, removing unused attributes like background
, and applying consistent use of classes are beneficial for maintaining clarity and ease of modification in future updates.
@@ -172,7 +191,7 @@ function initChart() { | |||
item.marker + | |||
' ' + | |||
item.seriesName + | |||
':' + | |||
i18n.global.t('commons.colon') + | |||
item.data + | |||
props.option.formatStr + | |||
'<br/>'; |
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 (
+
operator for cleaner readability. -
String Interpolation: Using ES6 string interpolation within the
t
method from Vue I18n can make the code more readable and concise.
Here's the optimized version using these techniques:
function initChart() {
switch (props.option.formatStr) {
case 'KB/s':
for (const item of datas) {
res +=
`${item.marker} ${i18n.global.t('chartSeries')}: ${computeSizeFromKBs(item.data)}\n`;
}
break;
case 'KB':
for (const item of datas) {
res +=
`${item.marker} ${i18n.global.t('chartSeries')}: ${computeSizeFromKB(item.data)}\n`;
}
break;
case 'MB':
for (const item of datas) {
res +=
`${item.marker} ${i18n.global.t('chartSeries')}: ${computeSizeFromMB(item.data)}\n`;
}
break;
default:
res +=
`${item.marker} ${i18n.global.t('chartSeries')}:\`${item.data}${props.option.formatStr}\`\n`;
}
}
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.
@@ -2578,6 +2588,7 @@ const message = { | |||
laddr: '本地地址/端口', | |||
raddr: '远程地址/端口', | |||
stopProcess: '结束', | |||
viewDetails: '查看详情', | |||
stopProcessWarn: '是否确定结束此进程 (PID:{0})?', | |||
processName: '进程名称', | |||
}, |
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 provided code snippet appears to be editing an object message
that likely contains localized strings for various parts of a user interface. Here are some general observations and suggestions:
Observations
-
Consistency in String Keys: The keys "true", "false", and "colon" should maintain uniqueness and consistency if used as keys.
-
Duplicate Strings: There are duplicate entries for certain string translations, such as
"remoteConnHelper"
appearing twice. This can make the structure inconsistent and might result in unexpected behavior. -
Missing Translation Entries: Not all expected translation strings are present in the provided data. A complete list would include options like "addDomainHelper", "domainConfigHelper", etc.
-
Special Characters: Proper handling of special characters (e.g., commas, backslashes) is crucial to maintaining correct formatting in UI elements.
-
Capitalization Consistency: Ensure consistent capitalization across similar phrases for better readability.
-
Unused Entries: Remove unnecessary entries to keep the code cleaner and efficient.
Suggestions
-
Remove Duplicates and Unused Entries:
const message = { // Maintain unique key-value pairs here... };
-
Expand Complete Translation List:
const message = { true: '是', false: '否', colon: ':', example: '例:', fit2cloud: '飞致云', lingxia: '凌霞', // Add more complete translations... };
-
Check Special Character Handling:
const message = { // Handle special character properly like this: remoteConnHelper: 'root 帐号远程连接 MySQL 有安全风险,开启需谨慎!' };
-
Ensure Capitalization Consistency:
const message = { true: '是', false: '否', colon: ':', example: '例:', fit2cloud: '飞致云', lingxia: '凌霞' }
-
Optimize Memory Usage:
If memory usage is a concern, consider merging adjacent objects where possible.
By addressing these points, you can ensure that the message
object remains clean and functional while adhering to best practices for localization.
} | ||
|
||
.system-content { | ||
font-size: 13px !important; | ||
border: none !important; | ||
width: 100% !important; | ||
} | ||
|
||
.monitor-tags { |
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 provided code changes appear to primarily involve translations and small adjustments within the HTML elements of a web application built with Vue.js. Here's my analysis:
Translation Changes
-
Lines 48-50:
<span>{{ $t('menu.website') }}</span> -> <span>{{ $t('menu.website', 2) }}</span>
This uses
v-t
interpolation (likely from i18nextVue or similar library). The addition of the second argument (2
) could indicate that it expects a plural form. -
Similar pattern throughout: The same logic is applied to other menu options like "Database," "Cron job," "System Info."
Recommendations:
Ensure that i18n
handles these plurals correctly and provides the appropriate plural forms in your locale files if necessary.
UI Adjustments
These changes also include minor styling updates to .system-content
.
- Classes added/removed:
- Removed borders from certain elements.
- Set backgrounds and widths to better fit the layout.
- Allowed text to wrap without overflowing content boxes.
Recommendation:
Keep an eye on how these styles affect accessibility and responsiveness across different screen resolutions and devices. Ensure proper fallbacks for elements that lose their basic style attributes.
Potential Issues
No significant issues arise from the code itself, but there might be related problems elsewhere in your app that you need to address, such as ensuring all translated strings contain valid plural forms or testing the app thoroughly after making these changes.
Overall, these updates should improve readability and maintainability while adhering to best practices.
@@ -172,7 +191,7 @@ function initChart() { | |||
item.marker + | |||
' ' + | |||
item.seriesName + | |||
':' + | |||
i18n.global.t('commons.colon') + | |||
item.data + | |||
props.option.formatStr + | |||
'<br/>'; |
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 you provided has several minor improvements that can be made:
-
Consistent String Interpolation: Ensure consistent usage of string interpolation (
i18n.global.t(...)
) throughout thecomputeSizeFrom*
function calls to improve readability. -
Remove Duplicate Code: Instead of repeating similar logic for different unit conversion strings, you can create a helper function that takes a value and returns its formatted result based on the current theme setting.
Here's an optimized version of the initChart
function with these changes applied:
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.
@@ -2578,6 +2586,7 @@ const message = { | |||
laddr: '本地地址/端口', | |||
raddr: '远程地址/端口', | |||
stopProcess: '结束', | |||
viewDetails: '查看详情', | |||
stopProcessWarn: '是否确定结束此进程 (PID:{0})?', | |||
processName: '进程名称', | |||
}, |
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.
Code Differences
Irregularities and Potential Issues:
-
Duplicate Key Error:
- The key "colon" appears twice within the
message
object, once with a value of':'
at line 4, and again as an empty string at lines 26 and 126.
- The key "colon" appears twice within the
-
Unused Keys:
- The keys
"colon"
at line 28 are also unused since it's assigned to an empty string. - The key
"noRefresh"
is repeated three times without explanation (lines 28, 97, and 127).
- The keys
-
String Formatting Errors:
- In several contexts, there are errors in string formatting where backticks (
)
should be replaced with single quotes ('') or other appropriate delimiters to ensure correct execution in JavaScript.
- In several contexts, there are errors in string formatting where backticks (
-
Typographical Errors:
- A small typo exists in one of the strings: "飞致云"
Optimization Suggestions:
-
Remove Unused Duplicates:
- Remove the duplicate keys "colon".
- If they can't be removed, explain their purpose if they serve different purposes elsewhere in the code.
-
Fix String Formatting Errors:
- Ensure that any string literals have consistently either single or double quotation marks. For example, replace
\r\n
with just\n
.
- Ensure that any string literals have consistently either single or double quotation marks. For example, replace
-
Correct Typographical Errors:
- Fix the typographical error in the string
"飞致云"
, replacing it with the proper name, assuming its intended spelling was indeed "飞致云".
- Fix the typographical error in the string
Overall, these changes will help improve the readability and maintainability of the codebase, ensuring fewer errors and improving user experience through better functionality.
} | ||
|
||
.system-content { | ||
font-size: 13px !important; | ||
border: none !important; | ||
width: 100% !important; | ||
} | ||
|
||
.monitor-tags { |
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.
Changes Summary
-
Localizations:
- Added
{{ $t('menu.website', 2) }}
,{{ $t('menu.database', 2) }}
, and{{ $t('menu.cronjob', 2) }}
to translate menu items.
- Added
-
Descriptions Component Enhancements:
- The
.el-descriptions
component now hasborder="true"
added directly inside it, changing its default style fromfalse
. - Labels within
el-descriptions-item
have been given a newlabel-class-name=".system-label"
with additional styles applied.
- The
-
System Status Section Adjustments:
- All elements under the
.h-systemInfo
class are updated to remove borders and backgrounds (border: "none"
,background: "none"
) while maintaining their width at "fit-content". - White space surrounding labels is removed for cleaner presentation (
white-space: nowrap
). - The description content remains unchanged for these sections except for text alignment (e.g.,
"text-align: center; line-height: 2em;"
;"line-height: normal;";
).
- All elements under the
-
Customizing Tooltip Styles in Menu Items:
New Tooltip Style:
.tooltip {
font-weight: 400 !important;
font-size: 16px !important;
color: var(--panel-tooltip-color);
};
Changes Summary of Tooltip Styling:
- Updated the
.tooltip
class to ensure better readability across different screen sizes. - Slightly increased the font size for tooltip texts.
These changes primarily focus on enhancing UI styling and localization efforts without altering fundamental functionalities.
@@ -172,7 +191,7 @@ function initChart() { | |||
item.marker + | |||
' ' + | |||
item.seriesName + | |||
':' + | |||
i18n.global.t('commons.colon') + | |||
item.data + | |||
props.option.formatStr + | |||
'<br/>'; |
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 provided code makes several changes that are intended to improve clarity and maintainability. Here’s a brief summary of the key points:
-
Imported
i18next
: The addition of importingi18n
allows better localization support. This ensures consistent use of internationalized text throughout the application. -
Internationalization: Multiple strings with hardcoded colons (
:
) have been replaced with localized equivalents usingi18n
. For example,'commons.colon'
. -
Consistent Formatting: Consistent spacing around operators and logical conditions improves readability.
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.
@@ -2578,6 +2586,7 @@ const message = { | |||
laddr: '本地地址/端口', | |||
raddr: '远程地址/端口', | |||
stopProcess: '结束', | |||
viewDetails: '查看详情', | |||
stopProcessWarn: '是否确定结束此进程 (PID:{0})?', | |||
processName: '进程名称', | |||
}, |
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 provided code snippet is for translations of messages into Chinese. However, some changes need to be made:
colon
key should only be set once for each language.noRefresh
can be removed since it's already defined.- Add missing translation keys like
'editPermissions'
,'sourceFile'
, and'viewDetails'
. - Capitalize
'ManageRemoteServers'
. - Use singular form for actions like
'executeScan'
.
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": "
|
Hi @wanghe-fit2cloud , please stop using AI with your account to review PRs. It's really troubling me and other reviewers. BTW, you can use GitHub Copilot code review, see https://docs.github.com/en/copilot/using-github-copilot/code-review/using-copilot-code-review for more. |
done. |
This reverts commit f843438.
What this PR does / why we need it?
This PR cherry-picks from #7232, #7247, #7318, #7353, #7358 and #7399, which applied for 1Panel v1.
Summary of your change
Please indicate you've done the following: