Compare commits

...

4 Commits

Author SHA1 Message Date
dc207a0138 test: lang parsing
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
See #652
2025-09-06 08:38:38 +02:00
02add8c3ef chore: make i18n
All checks were successful
continuous-integration/drone/push Build is passing
2025-09-06 08:28:53 +02:00
560d609013 test: ensure autocomplete output works
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
See #649
2025-09-06 08:26:50 +02:00
b4c9fbfe6d fix: use local flag
See #648
2025-09-06 08:24:37 +02:00
7 changed files with 59 additions and 15 deletions

View File

@ -217,12 +217,10 @@ Config:
i18n.G("help for abra"),
)
rootCmd.PersistentFlags().BoolVarP(
rootCmd.Flags().BoolVarP(
&internal.Version,
i18n.G("version"),
// FIXME: temporary workaround for #648
// i18n.G("v"),
"",
i18n.G("v"),
false,
i18n.G("version for abra"),
)

View File

@ -18,9 +18,11 @@ var assetFS embed.FS
var (
DefaultLocale = "en"
Locale = DefaultLocale
_, Mo = LoadLocale()
G = Mo.Get
)
func LoadLocale() *gotext.Mo {
func LoadLocale() (string, *gotext.Mo) {
entries, err := assetFS.ReadDir("locales")
if err != nil {
log.Fatalf("i18n: unable to read embedded locales directory: %s", err)
@ -49,7 +51,7 @@ func LoadLocale() *gotext.Mo {
}
if Locale == DefaultLocale {
return gotext.NewMo()
return Locale, gotext.NewMo()
}
b, err := assetFS.ReadFile(fmt.Sprintf("locales/%s.mo", Locale))
@ -60,7 +62,5 @@ func LoadLocale() *gotext.Mo {
mo := gotext.NewMo()
mo.Parse(b)
return mo
return Locale, mo
}
var G = LoadLocale().Get

21
pkg/i18n/i18n_test.go Normal file
View File

@ -0,0 +1,21 @@
package i18n_test
import (
"os"
"testing"
"coopcloud.tech/abra/pkg/i18n"
)
func TestLoadLocale(t *testing.T) {
originalLang := os.Getenv("LANG")
os.Setenv("LANG", "es_ES.UTF-8")
t.Cleanup(func() {
os.Setenv("LANG", originalLang)
})
locale, _ := i18n.LoadLocale()
if locale != "es" {
t.Fatalf("expected 'es', locale was '%s'", locale)
}
}

View File

@ -7,7 +7,7 @@
msgid ""
msgstr "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL\n"
"POT-Creation-Date: 2025-09-05 17:09-0400\n"
"POT-Creation-Date: 2025-09-06 08:28+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -5374,7 +5374,7 @@ msgstr ""
#. translators: `abra recipe versions` aliases. use a comma separated list of aliases
#. with no spaces in between
#: ./cli/app/backup.go:311 ./cli/app/restore.go:122 ./cli/recipe/version.go:19 ./cli/server/prune.go:107
#: ./cli/app/backup.go:311 ./cli/app/restore.go:122 ./cli/recipe/version.go:19 ./cli/run.go:223 ./cli/server/prune.go:107
msgid "v"
msgstr ""
@ -5421,7 +5421,7 @@ msgstr ""
msgid "version : %s, "
msgstr ""
#: ./cli/run.go:227
#: ./cli/run.go:225
msgid "version for abra"
msgstr ""

Binary file not shown.

View File

@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: EMAIL\n"
"POT-Creation-Date: 2025-09-05 17:09-0400\n"
"POT-Creation-Date: 2025-09-06 08:28+0200\n"
"PO-Revision-Date: 2025-09-04 08:14+0000\n"
"Last-Translator: chasqui <chasqui@cryptolab.net>\n"
"Language-Team: Spanish <https://translate.coopcloud.tech/projects/co-op-"
@ -5639,7 +5639,7 @@ msgstr ""
#. translators: `abra recipe versions` aliases. use a comma separated list of aliases
#. with no spaces in between
#: cli/app/backup.go:311 cli/app/restore.go:122 cli/recipe/version.go:19
#: cli/server/prune.go:107
#: cli/run.go:223 cli/server/prune.go:107
msgid "v"
msgstr ""
@ -5687,7 +5687,7 @@ msgstr ""
msgid "version : %s, "
msgstr ""
#: cli/run.go:227
#: cli/run.go:225
msgid "version for abra"
msgstr ""

View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
setup_file(){
load "$PWD/tests/integration/helpers/common"
_common_setup
}
setup(){
load "$PWD/tests/integration/helpers/common"
_common_setup
}
@test "autocomplete output works" {
run $ABRA autocomplete bash
assert_success
run $ABRA autocomplete fish
assert_success
run $ABRA autocomplete zsh
assert_success
run $ABRA autocomplete powershell
assert_success
}