-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support multiple language in track/session type/ room filter #236
Support multiple language in track/session type/ room filter #236
Conversation
Reviewer's Guide by SourceryThis pull request implements support for multiple languages in track, session type, and room filters. The changes primarily affect the filtering logic and data processing in the schedule views, introducing language-specific handling for session types, tracks, and rooms. File-Level Changes
Tips
|
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.
Hey @odkhang - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider extracting the common filtering logic in index.vue and sessions/index.vue into a shared utility function or mixin to avoid code duplication.
- The filtering logic, especially in the
filter()
computed property, has become quite complex. Consider refactoring this into smaller, more manageable functions to improve readability and maintainability.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
getLanguage() { | ||
return localStorage.getItem('userLanguage') || 'en' | ||
}, | ||
filterLanguage(data) { |
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.
suggestion: Refactor duplicate code in index.vue and sessions/index.vue
The filterLanguage function and related logic are duplicated in both index.vue and sessions/index.vue. Consider extracting this common functionality into a shared utility or mixin to improve maintainability and reduce code duplication.
import { filterLanguage } from '@/utils/languageUtils'
// ...
methods: {
filterLanguage,
// ... other methods
},
this.schedule.session_type.forEach(t => { | ||
if (typeof t.session_type === 'string') { | ||
setSessionType.add(t.session_type) | ||
} else { | ||
const sessionTypeKeyArray = Object.keys(t.session_type) | ||
let isEnglish = false | ||
|
||
for (let i = 0; i < sessionTypeKeyArray.length; i++) { | ||
if (sessionTypeKeyArray[i] === this.getLanguage()) { | ||
setSessionType.add(t.session_type[sessionTypeKeyArray[i]]) | ||
break | ||
} | ||
else if (sessionTypeKeyArray[i] === enLanguage) { | ||
isEnglish = true | ||
if (i === sessionTypeKeyArray.length - 1) { | ||
setSessionType.add(t.session_type[enLanguage]) | ||
} | ||
} | ||
else { | ||
if (i === sessionTypeKeyArray.length - 1) { | ||
if (isEnglish) { | ||
setSessionType.add(t.session_type[enLanguage]) | ||
} | ||
else { | ||
setSessionType.add(t.session_type[sessionTypeKeyArray[i]]) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) |
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.
suggestion: Simplify language selection logic for improved readability
The nested conditional statements in the language selection logic are complex and hard to follow. Consider refactoring this into a more declarative approach, possibly using a separate function or utilizing lodash methods for a more concise implementation.
this.schedule.session_type.forEach(t => {
const sessionType = typeof t.session_type === 'string' ? t.session_type : this.getSessionTypeByLanguage(t.session_type);
setSessionType.add(sessionType);
});
getSessionTypeByLanguage(sessionTypeObj) {
const languages = Object.keys(sessionTypeObj);
return sessionTypeObj[this.getLanguage()] || sessionTypeObj[enLanguage] || sessionTypeObj[languages[languages.length - 1]];
}
this PR about support multiple languages when filter track/session/room
Summary by Sourcery
Implement multi-language support for filtering tracks, session types, and rooms in the schedule view by leveraging user language preferences. Update the Vue configuration to set a global public path and adjust related asset paths. Introduce a BASE_PATH setting in the server configuration to facilitate dynamic URL path handling.
New Features:
Enhancements:
Build:
Deployment: