Skip to content
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

Improve update-locales script and fix locale processing bug #23240

Merged
merged 4 commits into from
Mar 2, 2023

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented Mar 2, 2023

The locales of Gitea has been broken for long time, till now, it's still not fully fixed.

One of the root problems is that the ini library is quite quirky and the update-locales script doesn't work well for all cases.

This PR fixes the update-locales script to make it satisfy ini library and the crowdin.

See the comments for more details.

The locale_zh-CN.ini is an example, it comes from crowdin and is processed by the new update-locales.sh. Especially see the feed_of: https://github.com/go-gitea/gitea/pull/23240/files#diff-321f6ca4eae1096eba230e93c4740f9903708afe8d79cf2e57f4299786c4528bR268

@codecov-commenter
Copy link

Codecov Report

Merging #23240 (5a1e6de) into main (33e556e) will increase coverage by 0.12%.
The diff coverage is 54.44%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main   #23240      +/-   ##
==========================================
+ Coverage   47.44%   47.56%   +0.12%     
==========================================
  Files        1140     1143       +3     
  Lines      150804   151076     +272     
==========================================
+ Hits        71549    71866     +317     
+ Misses      70788    70705      -83     
- Partials     8467     8505      +38     
Impacted Files Coverage Δ
cmd/serv.go 2.59% <0.00%> (-0.06%) ⬇️
models/actions/run.go 1.72% <0.00%> (+0.01%) ⬆️
models/actions/run_list.go 0.00% <0.00%> (ø)
models/actions/status.go 22.85% <0.00%> (-1.39%) ⬇️
models/actions/task.go 1.69% <0.00%> (-0.01%) ⬇️
models/auth/oauth2.go 60.52% <ø> (ø)
models/auth/twofactor.go 19.73% <ø> (ø)
models/db/engine.go 44.80% <ø> (ø)
models/unittest/testdb.go 12.92% <0.00%> (ø)
modules/auth/password/hash/pbkdf2.go 69.69% <ø> (ø)
... and 115 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 2, 2023
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 2, 2023
build/update-locales.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@zeripath zeripath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @wxiaoguang

I kept meaning to get round to looking at this as I suspected that something was going wrong to do with the ini output preparation.

This to me indicates again that we either need to get on with fixing go-ini or get off it.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 2, 2023
@zeripath
Copy link
Contributor

zeripath commented Mar 2, 2023

I'd also say we might want to consider making this script some go code instead

@wxiaoguang
Copy link
Contributor Author

I'd also say we might want to consider making this script some go code instead

Agree, and I prefer to get rid of the ini more 😁 if there is no buggy ini package, we do not need these tricks.

I think this PR is the last fix by modifying the script. Next time we should decide whether use Go to rewrite or totally replace the ini package.

build/update-locales.sh Outdated Show resolved Hide resolved
@lunny lunny added modifies/translation topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Mar 2, 2023
@lunny
Copy link
Member

lunny commented Mar 2, 2023

replace #23239

@jolheiser
Copy link
Member

🎺 🤖

@jolheiser jolheiser merged commit d72462d into go-gitea:main Mar 2, 2023
@jolheiser jolheiser removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 2, 2023
@wxiaoguang wxiaoguang deleted the fix-update-locales branch March 2, 2023 18:33
if [[ $OSTYPE == 'darwin'* ]]; then
# for macOS developers, use "brew install gnu-sed"
SED=gsed
fi
Copy link
Member

@silverwind silverwind Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just do the same detection that Makefile does and adapt sed command syntax based on whether it is GNU or BSD sed. Better than to require the installation of additional software :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check it out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Actually I have thought about this problem, but I didn't choose the sed -i'' for BSD sed, because the script has been here for long time, nobody really needs it, I just want to avoid any inconsistency. And I think this PR is the last fix by modifying the script 😂 in the future we should decide whether use Go to rewrite or totally replace the ini package.

The sed -i'' might also work, just like it in Makefile, but I haven't tested it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more explanations about my "worry about inconsistency": this script is hard to debug, and not covered by any test (unlike the sed in Makefile, any error can be found in the first time and gets fixed quickly). If there is any inconsistency between GNU sed and BSD sed, the problem can not be found until next crowdin sync runs, and it's difficult for macOS users to debug the inconsistency if they are using a different version.

If there is no inconsistency, then using sed -i'' is fine for BSD sed.

Just share some of my thoughts, for your information, no objection nor block. 😁

@wxiaoguang
Copy link
Contributor Author

I didn't know where this script runs in. If it runs in the environment without bash (really? it's 2023 now ...), I think we should also revert the shebang line to #!/bin/sh and remove the bash related if [[.

ps: I didn't see today's crowdin sync commit, does it mean that this script failed because I used bash in last PR?
I want to mention some maintainers but I don't know who knows the crwodin sync infrastructure ....

zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 3, 2023
* giteaofficial/main:
  Use async await to fix empty quote reply at first time (go-gitea#23168)
  Fix switched citation format (go-gitea#23250)
  Improve update-locales script and fix locale processing bug (go-gitea#23240)
  Refactor `ctx` in templates (go-gitea#23105)
  Improve frontend guideline (go-gitea#23252)
  Close the temp file when dumping database to make the temp file can be deleted on Windows (go-gitea#23249)

# Conflicts:
#	templates/repo/issue/view_content/context_menu.tmpl
@wxiaoguang
Copy link
Contributor Author

Sorry, I think it's incorrect to use bash in this script.

The last run fails:

https://drone.gitea.io/go-gitea/gitea/68658/1/3

3.17: Pulling from library/alpine
Digest: sha256:69665d02cb32192e52e07644d76bc6f25abeb5410edc1c7a81a10ba3f0efb90a
Status: Image is up to date for alpine:3.17
+ ./build/update-locales.sh
/bin/sh: ./build/update-locales.sh: not found

lunny pushed a commit that referenced this pull request Mar 31, 2023
…x some strings with semicolons (#23819)

Follow #23633 and #23240

Close #23814

Now we almost have a complete test set for Gitea's LocalStore.

This PR is still a quick fix for the legacy locale system (see the
TODOs), to resolve the problems fundamentally, it needs more work in the
future.
@delvh delvh added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Apr 3, 2023
@delvh delvh added this to the 1.20.0 milestone Apr 3, 2023
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/translation skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants