Switch to xgettext-go

This commit is contained in:
3wc
2025-08-26 14:23:46 -04:00
parent 29403740b5
commit 4589544906
4 changed files with 27 additions and 15 deletions

View File

@ -15,7 +15,7 @@ steps:
username: abra-bot
password:
from_secret: git_coopcloud_tech_token_abra_bot
repo: git.coopcloud.tech/toolshed/drone-xgotext
repo: git.coopcloud.tech/toolshed/drone-xgettext-go
registry: git.coopcloud.tech
tags: latest
purge: true

View File

@ -1,9 +1,15 @@
FROM golang:1.24-alpine AS build
RUN go install github.com/leonelquinteros/gotext/cli/xgotext@latest
RUN apk add git && \
git clone https://github.com/snapcore/snapd/ /tmp/snapd/ && \
cd /tmp/snapd/i18n/xgettext-go && \
go build
FROM golang:1.24-alpine
WORKDIR /drone/src
COPY --from=build /tmp/snapd/i18n/xgettext-go/xgettext-go /bin/xgettext-go
COPY plugin.sh /plugin/plugin.sh
ENTRYPOINT ["/plugin/plugin.sh"]

View File

@ -1,16 +1,18 @@
# drone-abra
# drone-xgettext-go
[![Build Status](https://build.coopcloud.tech/api/badges/toolshed/drone-abra/status.svg?ref=refs/heads/main)](https://build.coopcloud.tech/toolshed/drone-abra)
Use [`xgotext` ](https://github.com/leonelquinteros/gotext/tree/master/cli/xgotext) as a Drone plugin.
Use `xgettext-go` as a Drone plugin.
!!! warning "Caution!"
This is currently configured very specifically for use with Co-op Cloud abra. More customisability Coming Soon™, see #1
## Settings
### Optional
- **in**: (default: `/drone/src`) The source directory to scan for Gettext settings
- **out:** (default: `/drone/src/locales`) The target directory in which to create a `pot` file.
- **exclude** (default: `.git`) Comma-separated directories to exclude from processing
- **in**: (default: `/drone/src`) The source directory to scan for source files
- **out:** (default: `/drone/src/locales/default.pot`) The target directory in which to create a `pot` file.
## Example
@ -19,8 +21,8 @@ Use [`xgotext` ](https://github.com/leonelquinteros/gotext/tree/master/cli/xgote
kind: pipeline
name: Update Gettext catalog template
steps:
- name: Run xgotext
image: git.coopcloud.tech/toolshed/drone-xgotext
- name: Run xgettext-go
image: git.coopcloud.tech/toolshed/drone-xgettext-go
```
## Publishing

View File

@ -1,22 +1,26 @@
#!/bin/sh
set -e
set -ex
PLUGIN_IN=${PLUGIN_IN:-/drone/src/}
PLUGIN_OUT=${PLUGIN_OUT:-/drone/src/locales/}
PLUGIN_EXCLUDE=${PLUGIN_EXCLUDE:-}
PLUGIN_OUT=${PLUGIN_OUT:-/drone/src/locales/default.pot}
# PLUGIN_KEYWORD=${PLUGIN_KEYWORD:-gotext.Get}
run_xgotext_cmd() {
run_xgettext_cmd() {
echo "--- start command ---"
xgotext -v -in "$PLUGIN_IN" -out "$PLUGIN_OUT" ${PLUGIN_EXCLUDE:+-exclude} "$PLUGIN_EXCLUDE"
xgettext-go \
-o "$PLUGIN_OUT" \
--keyword="i18n.G" \
--sort-output \
$(find "$PLUGIN_IN" -name "*.go" -not -path '*vendor*')
echo "--- end command ---"
}
run_plugin() {
echo "--- start drone-xgotext ---"
run_xgotext_cmd
run_xgettext_cmd
echo "--- end drone-xgotext ---"
}