-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add change language option. #5693
Add change language option. #5693
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions 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. I understand the commands that are listed here. |
Welcome @theSinner! |
Codecov Report
@@ Coverage Diff @@
## master #5693 +/- ##
==========================================
- Coverage 44.39% 44.36% -0.03%
==========================================
Files 214 214
Lines 9119 9124 +5
Branches 113 113
==========================================
Hits 4048 4048
- Misses 4797 4802 +5
Partials 274 274
Continue to review full report at Codecov.
|
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 like the overall idea. I'd propose a few changes:
- Instead of keeping locales in the frontend, I'd move it to the backend and add a new endpoint to list supported locales. It can be a simple structure the same as the one used here.
- I'd remove cookie reading logic in the backend and use angular interceptor to alter the
Accept-Language
request header similar to what we do when injecting the token.
Because Angular needs the locale list to generate the dashboard for each locale, I think it's better to keep the config together to make future changes easier.
It was my first idea to inject the "Accept-Language" header, and it's okay for the requests that angular send them, but the problem is when we want to load the dashboard itself. Because in this case, the browser sends the request with default parameters, so we can't inject the custom "Accept-Language" header. I had three choices to send the language parameter:
Using query string and URL params cause more changes and I thought using cookies is a better idea. |
That's a valid point that I can agree with. I'd then move it to the As for the second point, it's true that the interceptor cannot be called before the app bundle is downloaded from the server. I did not think properly about the data flow here. Using cookie then seems like the easiest approach as we have to save this information in there anyway. |
Yes, you are right. Using "index.config" is a better idea. I didn't know this file exists. |
@theSinner you need to sign the cla(Contributor License Agreement ) 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. |
Actually, I signed the cla. Maybe I should comment "I signed it" here to recheck. |
I signed it |
@theSinner your commits are missing user/email information. You need to configure git to use proper email when signing the commits. |
a82a249
to
fbe2923
Compare
I fixed the name and email of the last commit, but the cla check still failed. Should I change the previous commits' email/name too? |
Squash commits into a single commit, rebase and push force. |
… Make lang value in cookie the most important, then the env variable and the least important is the default browser header.
fbe2923
to
1469b1e
Compare
02f7532
to
7135a91
Compare
@theSinner I have refactored code a bit and fixed the language caching issue where the browser would not reload language due to naming of output build files. I have also disabled language selector while in dev mode as it would not work anyway. Thank you for your help and for creating the PR. I think it will really help Dashboard users. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: floreks, theSinner The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thank you for your time and help to fix the issues. |
Hi
I added the "choose language" option in the settings.
After choosing a language, the frontend side sets the language code in the cookie and reload the dashboard and the backend side checks the cookie before checking the "Accept-Language" header and load the dashboard based on the selected language.