[go: up one dir, main page]

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

Add change detection to make i18n for easier commit #14118

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

simondeziel
Copy link
Member

This tries to add some basic change detection to make update-pot, make update-po and the meta target make i18n so that they suggest committing changes with a "canned" message.

@simondeziel simondeziel changed the title Improve make i18n to ask to commit on changes if any Add change detection to make i18n for easier commit Sep 16, 2024
@simondeziel simondeziel marked this pull request as ready for review September 16, 2024 22:53
@simondeziel
Copy link
Member Author

Here's what it looks like to produce the last commit:

$ make i18n
(cd / ; go install github.com/snapcore/snapd/i18n/xgettext-go@2.57.1)
xgettext-go -o po/lxd.pot --add-comments-tag=TRANSLATORS: --sort-output --package-name=lxd --msgid-bugs-address=lxd@lists.canonical.com --keyword=i18n.G --keyword-plural=i18n.NG lxc/*.go lxc/*/*.go
if git diff --quiet --ignore-matching-lines='^\s*"POT-Creation-Date: .*\n"' -- po/*.pot; then git checkout -- po/*.pot; fi
if [ -t 0 ] && ! git diff --quiet --ignore-matching-lines='^\s*"POT-Creation-Date: .*\n"' -- po/*.pot; then \
	read -rp "Would you like to commit i18n template changes (Y/n)? " answer; \
		if [ "${answer:-y}" = "y" ] || [ "${answer:-y}" = "Y" ]; then \
			git commit -sm "i18n: Update translation templates." -- po/*.pot; fi; \
fi
set -eu; \
for lang in po/ar po/ber po/bg po/ca po/cs po/de po/el po/eo po/es po/fa po/fi po/fr po/he po/hi po/id po/it po/ja po/ka po/ko po/mr po/nb_NO po/nl po/pa po/pl po/pt_BR po/pt po/ru po/si po/sl po/sr po/sv po/te po/th po/tr po/tzm po/ug po/uk po/zh_Hans po/zh_Hant; do\
    msgmerge --backup=none -U $lang.po po/lxd.pot; \
done; \
if [ -t 0 ] && ! git diff --quiet -- po/*.po; then \
	read -rp "Would you like to commit i18n changes (Y/n)? " answer; \
		if [ "${answer:-y}" = "y" ] || [ "${answer:-y}" = "Y" ]; then \
			git commit -sm "i18n: Update translations." -- po/*.po; fi; \
fi
....................................................................................................................................................................... done.
........................................................................................................................................................................ done.
......................................................................................................................................................................... done.
......................................................................................................................................................................... done.
......................................................................................................................................................................... done.
.......................................................................................................................................................................................... done.
................................................................................................................................................................................................................................. done.
.......................................................................................................................................................................................... done.
..................................................................................................................................................................................... done.
................................................................................................................................................................................... done.
........................................................................................................................................................................................ done.
.......................................................................................................................................................................................... done.
.................................................................................................................................................................................... done.
.......................................................................................................................................................................... done.
...................................................................................................................................................................... done.
.................................................................................................................................................................................... done.
............................................................................................................................................................................. done.
..................................................................................................................................................................................... done.
................................................................................................................................................................................. done.
.................................................................................................................................................................................................... done.
............................................................................................................................................................................................... done.
........................................................................................................................................................................................................................ done.
.............................................................................................................................................................................................. done.
.......................................................................................................................................................................... done.
....................................................................................................................................................................................... done.
...................................................................................................................................................................................... done.
.................................................................................................................................................................................................................................................... done.
................................................................................................................................................................................... done.
................................................................................................................................................................................ done.
............................................................................................................................................................................... done.
................................................................................................................................................................................. done.
................................................................................................................................................................................. done.
............................................................................................................................................................................................................. done.
.................................................................................................................................................................................... done.
........................................................................................................................................................................................... done.
..................................................................................................................................................................................... done.
................................................................................................................................................................................. done.
.............................................................................................................................................................................................. done.
................................................................................................................................................................................... done.
Would you like to commit i18n changes (Y/n)? y
[i18n-commit-on-changes 90e656dba8] i18n: Update translations.
 39 files changed, 2574 insertions(+), 2574 deletions(-)

Copy link
Member
@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

I believe we run this in the CI to check for missing commits, will this block on stdin in those cases?

Copy link
Member
@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

I believe we run this in the CI to check for missing commits, will this block on stdin in those cases?

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
@simondeziel
Copy link
Member Author

The make i18n check done in test/lint/i18n-up-to-date.sh behaves correctly when stdin is closed:

$ test/lint/i18n-up-to-date.sh </dev/null
Checking that the .pot files are up to date...
................................................................................................................................................................................. done.
...

It doesn't prompt for making any commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants