mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
kubectl: use embedded translations instead of generated bindata
Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
This commit is contained in:
parent
5ece28b77a
commit
eb75b34394
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user