kubectl: use embedded translations instead of generated bindata

Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
This commit is contained in:
Nabarun Pal 2021-03-04 10:26:41 +05:30
parent 5ece28b77a
commit eb75b34394
No known key found for this signature in database
GPG Key ID: 611D5079D826B150
2 changed files with 9 additions and 3 deletions

View File

@ -19,17 +19,19 @@ package i18n
import ( import (
"archive/zip" "archive/zip"
"bytes" "bytes"
"embed"
"errors" "errors"
"fmt" "fmt"
"os" "os"
"strings" "strings"
"k8s.io/kubectl/pkg/generated"
"github.com/chai2010/gettext-go/gettext" "github.com/chai2010/gettext-go/gettext"
"k8s.io/klog/v2" "k8s.io/klog/v2"
) )
//go:embed translations
var translations embed.FS
var knownTranslations = map[string][]string{ var knownTranslations = map[string][]string{
"kubectl": { "kubectl": {
"default", "default",
@ -112,7 +114,7 @@ func LoadTranslations(root string, getLanguageFn func() string) error {
if err != nil { if err != nil {
return err return err
} }
data, err := generated.Asset(filename) data, err := translations.ReadFile(filename)
if err != nil { if err != nil {
return err return err
} }

View File

@ -42,6 +42,10 @@ We use the English translation as the `msgid`.
## Regenerating the bindata file ## Regenerating the bindata file
> Note: Regeneration of bindata is no more necessary for Kubernetes 1.22+ as
> the translations are now embedded into the binary at compile time.
> See: https://github.com/kubernetes/kubernetes/pull/99829
With the `mo` files up to date, you can now convert the generated files With the `mo` files up to date, you can now convert the generated files
into code using `go-bindata` command which can be installed with: into code using `go-bindata` command which can be installed with: