-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: Some adjustments to internationalization #7332
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
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
|
||
| if (to.name !== 'entrance' && !globalStore.isLogin) { | ||
| next({ | ||
| name: 'entrance', |
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.
There are no apparent errors or issues with this code. However, there is an opportunity for further optimization:
- Code DRYing: The
next({ name: '404' });line appears twice in the same branch. Consider extracting it into a separate function call to make the code cleaner.
Here's how you can optimize it:
@@ -10,6 +10,9 @@ router.beforeEach((to, from, next) => {
axiosCanceler.removeAllPending();
const globalStore = GlobalStore();
+ handleUnauthorizedRoute(next);
+
if (!globalStore.isLogin && to.name !== 'entrance') {
next({
name: 'entrance',Create this helper function:
function handleUnauthorizedRoute(next) {
nprogress.done()
if(to.path.includes('xpack')){
return
}
console.log("Unauthorized path")
// You may want to log more specific information here, like the current route
}This way, the duplicate code block is removed and organized under its own named function, improving readability and maintainability.
| <el-radio v-if="!globalStore.isIntl" value="en">English</el-radio> | ||
| </el-radio-group> | ||
| </el-form-item> | ||
|
|
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 have duplication of "English" radio options. It should be cleaned up to avoid this repetition:
@@ -77,13 +77,12 @@
@change="onSave('Language', form.language)"
v-model="form.language"
>
- <el-radio value="en">English</el-radio>
+ <!-- Remove duplicate English radio option -->
</el-radio-group>
</el-form-item>
Additionally, you may want to consider using conditional rendering within the el-radio components based on some logic rather than hardcoding them like this. For example, if globalStore.isIntl determines whether certain fields need certain visibility or not, it might make more sense to use conditional statements instead of repeating the same HTML twice with different values.
If there's additional context about what these changes will achieve (like improving accessibility by hiding one of the radios), feel free to include that information for further clarification.
| let checkedLabels: any[] = []; | ||
| if (!globalStore.isIntl) { | ||
| const res = await getSettingInfo(); | ||
| const json: Node = JSON.parse(res.data.xpackHideMenu); |
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 change seems mostly correct, but here's a quick review:
-
Type of
checkedLabels: The linelet checkedLabels: string | any[];specifies thatcheckedLabelscan be either a string or an array of any type (any[]). Ensure that this is intentional as it might lead to runtime errors if you expectcheckedLabelsto always be a string when used. -
Potential Issue with
globalStore.isIntl: Before assigning the value fromgetSettingInfo, ensure there isn't a race condition whereglobalStore.isIntlhasn't been initialized yet (e.g., using asynchronous operations outside this block). -
Suggested Change: Consider initializing
checkedLabelswithin the same scope as its definition without specifying types first, especially if types are not strictly necessary for all use cases (although they can help improve readability):const search = async () => { await checkIsSystemIntl(); let checkedLabels; if (!globalStore.isIntl) { const res = await getSettingInfo(); globalStore.setLocale(res.data.xpackHideMenu); // Assuming setLocale updates isCheckedLabels based on xpackHideMenu data checkedLabels = globalStore.isCheckedLabels || []; } else { checkedLabels = []; // Alternatively set labels based on intl system settings or default values } doSomethingWith(checkedLabels); };
This approach assumes setCheckedLabels method exists in globalStore.
-
If
isCheckedLabelsdoesn’t exist, consider setting its initial value ininitfunction before callingsearch. This would prevent undefined behavior:import { init } from "./store"; init() { globalStore.isCheckedLabels = []; // Set initial state if needed } async search() { await ... }
These optimizations focus on clarity and ensuring the flow is smooth without introducing unnecessary complexity or runtime error risks.
|
wanghe-fit2cloud
left a comment
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.
/lgtm
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wanghe-fit2cloud The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |



No description provided.