Compare commits
4 Commits
feature/3w
...
main
Author | SHA1 | Date | |
---|---|---|---|
dc207a0138
|
|||
02add8c3ef
|
|||
560d609013
|
|||
b4c9fbfe6d
|
@ -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"),
|
||||
)
|
||||
|
@ -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
21
pkg/i18n/i18n_test.go
Normal 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)
|
||||
}
|
||||
}
|
@ -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.
@ -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 ""
|
||||
|
||||
|
25
tests/integration/autocomplete.bats
Normal file
25
tests/integration/autocomplete.bats
Normal 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
|
||||
}
|
Reference in New Issue
Block a user