Use xgettext-go instead of xgotext #1

Closed
opened 2025-08-23 14:36:06 +00:00 by decentral1se · 2 comments
Owner

@3wordchant from the WIP rabbit hole of toolshed/abra#608...

I'll spare you the gory details (unless you care) but I am now running:

xgettext-go \
  -o pkg/i18n/locales/abra.pot \
  --keyword=i18n.G \
  --sort-output \
  $(find . -name "*.go" -not -path "*vendor*")

Which finishes in 1/3 of a second vs. the 10+ minutes or so it takes xgotext. You can grab it with: go install -v -x github.com/snapcore/snapd/i18n/xgettext-go@2.57.1 Coming from 8a2598a524/Makefile (L270-L291). I'm pretty convinced this tool is reliable since incus is a huge project which has existed for years...

It probably makes sense to wait till the dust settles in toolshed/abra#608 before making the switch here...

@3wordchant from the WIP rabbit hole of https://git.coopcloud.tech/toolshed/abra/pulls/608... I'll spare you the gory details (unless you care) but I am now running: ```bash xgettext-go \ -o pkg/i18n/locales/abra.pot \ --keyword=i18n.G \ --sort-output \ $(find . -name "*.go" -not -path "*vendor*") ``` Which finishes in 1/3 of a second vs. the 10+ minutes or so it takes `xgotext`. You can grab it with: `go install -v -x github.com/snapcore/snapd/i18n/xgettext-go@2.57.1` Coming from https://github.com/lxc/incus/blob/8a2598a524bbe5581e0ce62d2ae99262199a4717/Makefile#L270-L291. I'm pretty convinced this tool is reliable since `incus` is a huge project which has existed for years... It probably makes sense to wait till the dust settles in https://git.coopcloud.tech/toolshed/abra/pulls/608 before making the switch here...
Author
Owner

make i18n is pretty damn fast now 👇

Makefile Lines 67 to 94 in 4e205cf13e
.PHONY: i18n
i18n: update-pot update-pot-po-metadata update-po build-mo
.PHONY: update-po
update-po:
@set -eu; \
for lang in $(LINGUAS); do \
msgmerge --backup=none -U $$lang.po pkg/i18n/locales/$(DOMAIN).pot; \
done
.PHONY: update-pot
update-pot:
@xgettext-go \
-o pkg/i18n/locales/$(DOMAIN).pot \
--keyword=i18n.G \
--sort-output \
$$(find . -name "*.go" -not -path "*vendor*")
.PHONY: update-pot-po-metadata
update-pot-po-metadata:
@sed -i "s/charset=CHARSET/charset=UTF-8/g" pkg/i18n/locales/*.po*
.PHONY: build-mo
build-mo:
@set -eu; \
for lang in $(POFILES); do \
msgfmt $$lang -o $$(echo $$lang | sed 's/.po/.mo/g') --statistics; \
done

`make i18n` is pretty damn fast now 👇 https://git.coopcloud.tech/toolshed/abra/src/commit/4e205cf13e3878ef4c4194f71ec08f329a9d8c6c/Makefile#L67-L94
Author
Owner

It's here 🤘

It's here 🤘
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: toolshed/drone-xgettext-go#1
No description provided.