-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Fix missing translations when updating username. #3564
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
Unit tests fail for this PR because they are hardcoded to look for the faulty |
Tests should be updated also in this PR |
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.
Just need to also update
gitea/integrations/user_test.go
Line 95 in befa744
i18n.Tr("en", "user.newName_reserved"), |
integrations/user_test.go
Outdated
@@ -92,7 +92,7 @@ func TestRenameReservedUsername(t *testing.T) { | |||
htmlDoc := NewHTMLParser(t, resp.Body) | |||
assert.Contains(t, | |||
htmlDoc.doc.Find(".ui.negative.message").Text(), | |||
i18n.Tr("en", "user.newName_reserved"), | |||
i18n.Tr("en", "form.name_reserved", reservedUsername), |
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 i18n.Tr("en", "user.form.name_reserved", reservedUsername)
You just forgot the user.
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 did your exact change, but that fails because i18n.Tr
doesn't parse the %s
format specifier in the translation string. See the CI report.
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.
No you write form.name_reserved
not user.form.name_reserved
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.
If it can find the string in translations it will default to the trad name so in your case name_reserved or previously newName_reserved and add all extra string that are not in the translated format after.
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.
@sapk Thanks for the coaching, I've updated my branch again. Waiting for the CI now.
Edit: Bring out the champagne. It works!
Codecov Report
@@ Coverage Diff @@
## master #3564 +/- ##
=======================================
Coverage 35.79% 35.79%
=======================================
Files 285 285
Lines 40866 40866
=======================================
Hits 14630 14630
- Misses 24066 24067 +1
+ Partials 2170 2169 -1
Continue to review full report at Codecov.
|
Thanks to @sapk coaching everything now seems to be in order. |
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.
Thanks for the contrib.
Gitea tries to display non-existing translation strings after failing to update a username on the 'Your Settings' page. This PR (hopefully) fixes three error cases. I'm no Go expert and I can't test this, but I think it should work.