-
Notifications
You must be signed in to change notification settings - Fork 34
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
LanguageFood on develop branch #349
Conversation
"title":"Sprache für den Speiseplan", | ||
"german":"Deutsch", | ||
"english":"Englisch", | ||
"default":"Standart" |
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.
Should be "Standard" :)
@@ -17,6 +17,12 @@ | |||
"showReimannsStatic": "Reimanns anzeigen (feste Gerichte)", | |||
"showCanisius": "Canisiuskonvikt anzeigen" | |||
}, | |||
"languageFood":{ | |||
"title":"Sprache für den Speiseplan", | |||
"german":"Deutsch", |
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.
We already have the translated Lang names in the languages.json
. Therefore, we shouldn't redefine them here, especially when we add new languages.
@@ -17,6 +17,12 @@ | |||
"showReimannsStatic": "Show Reimanns (static meals)", | |||
"showCanisius": "Show Canisius Convict" | |||
}, | |||
"languageFood":{ | |||
"title":"Language for food menu", | |||
"german":"German", |
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.
Same here
onChange={() => toggleSelectedLanguageFood('default')} | ||
type={'radio'} // ohne type ist es eine checkbox | ||
/> | ||
<Form.Check |
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.
In the best case, these options should be created dynamically based on the supported languages (see LanguageModal.jsx
).
preferencesSelection, | ||
allergenSelection | ||
} = useContext(FoodFilterContext) | ||
const { i18n, t } = useTranslation(['dashboard', 'food']) | ||
|
||
let languageFood = '' |
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.
This can be simplified to:
const languageFood = selectedLanguageFood && selectedLanguageFood !== 'default' ? selectedLanguageFood : i18n.languages[0]
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.
I do not think the &&
and ? :
operators should be mixed without braces, as the precendence might not be clear to the reader
@@ -30,6 +38,7 @@ import { useEffect, useState } from 'react' | |||
* @returns {void} | |||
*/ | |||
export function useFoodFilter () { | |||
const [selectedLanguageFood, setSelectedLanguageFood] = useState([]) |
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.
To use the proposed simplification, change the useState default to 'default'
rogue-thi-app/pages/food.jsx
Outdated
@@ -59,7 +60,15 @@ export default function Mensa () { | |||
const userKind = useUserKind() | |||
const router = useRouter() | |||
const { i18n, t } = useTranslation('food') | |||
const currentLocale = i18n.languages[0] | |||
|
|||
let languageFood = '' |
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.
Can be simplified to:
const currentLocale = selectedLanguageFood && selectedLanguageFood !== 'default' ? selectedLanguageFood : i18n.languages[0]
Therefore, all the languageFood
referenced should be changed to currentLocale
@pl0ss We can also look at the PR tomorrow again in detail at the Hackathon. Thanks a lot for your improvements :) |
🤖 Generated by Copilot at 91e571b
Summary
🌐🍽️🛠️
This pull request adds a new feature to the food section of the app, which allows the user to select a language for the food menu (default, German or English). It modifies the
FoodCard
,FilterFoodModal
,useFoodFilter
andFood
components, as well as thecommon.json
files for the German and English locales, to implement the feature.Walkthrough
default
,de
oren
) (link, link, link, link, link, link, link, link, link, link, link, link, link)selectedLanguageFood
prop and state to access and update the user's choice of language for the food menu in theFoodCard
,FilterFoodModal
andFood
components (link, link, link, link, link, link, link, link, link, link)i18n.languages[0]
withlanguageFood
variable in theFoodCard
andFood
components to display the food names and descriptions in the user's chosen language for the food menu (link, link, link, link, link, link, link, link)