From 12bb8c5c250510095f39bf21dd09f0506baababc Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Mon, 24 Jun 2019 15:15:01 -0700 Subject: [PATCH 1/4] Add translation files into the minikube binary --- .gitignore | 1 + Makefile | 17 +++++++++++------ pkg/minikube/translate/translate.go | 5 ++--- .../translations => translations}/fr-FR.json | 0 .../translations => translations}/zh-CN.json | 0 5 files changed, 14 insertions(+), 9 deletions(-) rename {pkg/minikube/translate/translations => translations}/fr-FR.json (100%) rename {pkg/minikube/translate/translations => translations}/zh-CN.json (100%) diff --git a/.gitignore b/.gitignore index b684563a1c..1f55d284e7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ _testmain.go deploy/iso/minikube-iso/board/coreos/minikube/rootfs-overlay/etc/VERSION /pkg/minikube/assets/assets.go +/pkg/minikube/translate/translations.go /minikube .DS_Store diff --git a/Makefile b/Makefile index 0d08651886..d14527014b 100755 --- a/Makefile +++ b/Makefile @@ -106,7 +106,7 @@ out/minikube$(IS_EXE): out/minikube-$(GOOS)-$(GOARCH)$(IS_EXE) out/minikube-windows-amd64.exe: out/minikube-windows-amd64 cp out/minikube-windows-amd64 out/minikube-windows-amd64.exe -out/minikube-%: pkg/minikube/assets/assets.go $(shell find $(CMD_SOURCE_DIRS) -type f -name "*.go") +out/minikube-%: pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go $(shell find $(CMD_SOURCE_DIRS) -type f -name "*.go") ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y) $(call DOCKER,$(BUILD_IMAGE),/usr/bin/make $@) else @@ -157,11 +157,11 @@ iso_in_docker: --user $(shell id -u):$(shell id -g) --env HOME=/tmp --env IN_DOCKER=1 \ $(ISO_BUILD_IMAGE) /bin/bash -test-iso: pkg/minikube/assets/assets.go +test-iso: pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go go test -v ./test/integration --tags=iso --minikube-args="--iso-url=file://$(shell pwd)/out/buildroot/output/images/rootfs.iso9660" .PHONY: test-pkg -test-pkg/%: pkg/minikube/assets/assets.go +test-pkg/%: pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go go test -v -test.timeout=60m ./$* --tags="$(MINIKUBE_BUILD_TAGS)" .PHONY: all @@ -183,7 +183,7 @@ integration-versioned: out/minikube go test -v -test.timeout=60m ./test/integration --tags="$(MINIKUBE_INTEGRATION_BUILD_TAGS) versioned" $(TEST_ARGS) .PHONY: test -test: pkg/minikube/assets/assets.go +test: pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go ./test.sh # Regenerates assets.go when template files have been updated @@ -191,6 +191,10 @@ pkg/minikube/assets/assets.go: $(shell find deploy/addons -type f) which go-bindata || GO111MODULE=off GOBIN=$(GOPATH)/bin go get github.com/jteeuwen/go-bindata/... PATH="$(PATH):$(GOPATH)/bin" go-bindata -nomemcopy -o pkg/minikube/assets/assets.go -pkg assets deploy/addons/... +pkg/minikube/translate/translations.go: $(shell find translations/ -type f) + which go-bindata || GO111MODULE=off GOBIN=$(GOPATH)/bin go get github.com/jteeuwen/go-bindata/... + PATH="$(PATH):$(GOPATH)/bin" go-bindata -nomemcopy -o pkg/minikube/translate/translations.go -pkg translate translations/... + .PHONY: cross cross: out/minikube-linux-$(GOARCH) out/minikube-darwin-amd64 out/minikube-windows-amd64.exe @@ -210,6 +214,7 @@ checksum: clean: rm -rf $(BUILD_DIR) rm -f pkg/minikube/assets/assets.go + rm -f pkg/minikube/translate/translations.go rm -rf ./vendor .PHONY: gendocs @@ -241,7 +246,7 @@ out/linters/golangci-lint: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b out/linters $(GOLINT_VERSION) .PHONY: lint -lint: pkg/minikube/assets/assets.go out/linters/golangci-lint +lint: pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go out/linters/golangci-lint ./out/linters/golangci-lint run \ --deadline 4m \ --build-tags "${MINIKUBE_INTEGRATION_BUILD_TAGS}" \ @@ -259,7 +264,7 @@ reportcard: mdlint: @$(MARKDOWNLINT) $(MINIKUBE_MARKDOWN_FILES) -out/docs/minikube.md: $(shell find cmd) $(shell find pkg/minikube/constants) pkg/minikube/assets/assets.go +out/docs/minikube.md: $(shell find cmd) $(shell find pkg/minikube/constants) pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go go run -ldflags="$(MINIKUBE_LDFLAGS)" hack/help_text/gen_help_text.go out/minikube_$(DEB_VERSION).deb: out/minikube-linux-amd64 diff --git a/pkg/minikube/translate/translate.go b/pkg/minikube/translate/translate.go index 2fb2a599e1..f47d0930ec 100644 --- a/pkg/minikube/translate/translate.go +++ b/pkg/minikube/translate/translate.go @@ -18,7 +18,6 @@ package translate import ( "encoding/json" - "io/ioutil" "strings" "github.com/cloudfoundry-attic/jibber_jabber" @@ -74,8 +73,8 @@ func DetermineLocale() { } // Load translations for preferred language into memory. - translationFile := "pkg/minikube/translate/translations/" + preferredLanguage.String() + ".json" - t, err := ioutil.ReadFile(translationFile) + translationFile := "translations/" + preferredLanguage.String() + ".json" + t, err := Asset(translationFile) if err != nil { glog.Infof("Failed to load translation file for %s: %v", preferredLanguage.String(), err) return diff --git a/pkg/minikube/translate/translations/fr-FR.json b/translations/fr-FR.json similarity index 100% rename from pkg/minikube/translate/translations/fr-FR.json rename to translations/fr-FR.json diff --git a/pkg/minikube/translate/translations/zh-CN.json b/translations/zh-CN.json similarity index 100% rename from pkg/minikube/translate/translations/zh-CN.json rename to translations/zh-CN.json From 8a4776b250e78faf50e9680db7772d1ca7e95a52 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Mon, 24 Jun 2019 15:18:31 -0700 Subject: [PATCH 2/4] Fixing top level extract call for new translations directory location --- cmd/extract/extract.go | 4 ++-- translations/fr-FR.json | 2 +- translations/zh-CN.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/extract/extract.go b/cmd/extract/extract.go index f4ebf0a5d8..998ca7221d 100644 --- a/cmd/extract/extract.go +++ b/cmd/extract/extract.go @@ -16,7 +16,7 @@ limitations under the License. /* This file scans all of minikube's code and finds all strings that need to be able to be translated. It uses the more generic extract.TranslatableStringd, and prints all the translations -into every json file it can find in pkg/minikube/translate/translations. +into every json file it can find in the translations directory. Usage: from the root minikube directory, go run cmd/extract/extract.go */ @@ -30,7 +30,7 @@ import ( func main() { paths := []string{"cmd", "pkg"} functions := []string{"translate.T"} - output := "pkg/minikube/translate/translations" + output := "translations" err := extract.TranslatableStrings(paths, functions, output) if err != nil { diff --git a/translations/fr-FR.json b/translations/fr-FR.json index f0135e1afa..5a6149df3d 100644 --- a/translations/fr-FR.json +++ b/translations/fr-FR.json @@ -120,6 +120,7 @@ "Opening %s in your default browser...": "", "Opening kubernetes service %s/%s in default browser...": "", "Options: %s": "", + "Please don't run minikube as root or with 'sudo' privileges. It isn't necessary.": "", "Please enter a value:": "", "Please specify the directory to be mounted: \n\tminikube mount \u003csource directory\u003e:\u003ctarget directory\u003e (example: \"/host-home:/vm-home\")": "", "Powering off %q via SSH ...": "", @@ -193,7 +194,6 @@ "addon list failed": "", "api load": "", "bash completion failed": "", - "checking main repository and mirrors for images": "", "command runner": "", "config view failed": "", "disable failed": "", diff --git a/translations/zh-CN.json b/translations/zh-CN.json index d7c691b694..df12adee8c 100644 --- a/translations/zh-CN.json +++ b/translations/zh-CN.json @@ -120,6 +120,7 @@ "Opening %s in your default browser...": "", "Opening kubernetes service %s/%s in default browser...": "", "Options: %s": "", + "Please don't run minikube as root or with 'sudo' privileges. It isn't necessary.": "", "Please enter a value:": "", "Please specify the directory to be mounted: \n\tminikube mount \u003csource directory\u003e:\u003ctarget directory\u003e (example: \"/host-home:/vm-home\")": "", "Powering off %q via SSH ...": "", @@ -193,7 +194,6 @@ "addon list failed": "", "api load": "", "bash completion failed": "", - "checking main repository and mirrors for images": "", "command runner": "", "config view failed": "", "disable failed": "", From 015117e04a3014857c82470e1d796540c195785f Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Mon, 24 Jun 2019 15:34:24 -0700 Subject: [PATCH 3/4] Ignore generated file for boilerplate --- go.sum | 8 -------- test.sh | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/go.sum b/go.sum index b336602e11..fb9399dd7a 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= -github.com/BurntSushi/toml v0.3.0 h1:e1/Ivsx3Z0FVTV0NSOv/aVgbUWyQuzj7DDnFblkRvsY= -github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Parallels/docker-machine-parallels v1.3.0 h1:RG1fyf3v1GwXMCeHRiZkB4tL9phFZEv6ixcvRZ1raN8= github.com/Parallels/docker-machine-parallels v1.3.0/go.mod h1:HCOMm3Hulq/xuEVQMyZOuQlA+dSZpFY5kdCTZWjMVis= github.com/Sirupsen/logrus v0.0.0-20170822132746-89742aefa4b2 h1:k1A7eIeUk6rnX2yuagwljW/pDezkK8oSpvPumT9zdZY= @@ -129,8 +127,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/nicksnyder/go-i18n/v2 v2.0.0-beta.7 h1:wCBv/ZWBkVl/x3xvw4MAMXgjtYbzyNTcZXO5jpmVQuA= -github.com/nicksnyder/go-i18n/v2 v2.0.0-beta.7/go.mod h1:JXS4+OKhbcwDoVTEj0sLFWL1vOwec2g/YBAxZ9owJqY= github.com/olekukonko/tablewriter v0.0.0-20160923125401-bdcc175572fd h1:nEatQ6JnwCT9iYD5uqYUiFqq8tJGX25to8KVKXqya7k= github.com/olekukonko/tablewriter v0.0.0-20160923125401-bdcc175572fd/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -210,8 +206,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJV golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c h1:uOCk1iQW6Vc18bnC13MfzScl+wdKBmM9Y9kU7Z83/lw= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190115181402-5dab4167f31c h1:pcBdqVcrlT+A3i+tWsOROFONQyey9tisIQHI4xqVGLg= golang.org/x/oauth2 v0.0.0-20190115181402-5dab4167f31c/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -236,8 +230,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20161028155119-f51c12702a4d h1:TnM+PKb3ylGmZvyPXmo9m/wktg7Jn/a/fNmr33HSj8g= golang.org/x/time v0.0.0-20161028155119-f51c12702a4d/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c h1:97SnQk1GYRXJgvwZ8fadnxDOWfKvkNQHH3CtZntPSrM= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/test.sh b/test.sh index b47493a590..75d119acba 100755 --- a/test.sh +++ b/test.sh @@ -28,7 +28,7 @@ make -s lint && echo ok || ((exitcode+=4)) echo "= boilerplate ===========================================================" readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python) readonly BDIR="./hack/boilerplate" -missing="$($PYTHON ${BDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BDIR} | grep -v \/assets.go || true)" +missing="$($PYTHON ${BDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BDIR} | grep -v \/assets.go | grep -v \/translations.go || true)" if [[ -n "${missing}" ]]; then echo "boilerplate missing: $missing" echo "consider running: ${BDIR}/fix.sh" From cab5d309009266c3c51eaae4df14bc27b00b280e Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Mon, 24 Jun 2019 16:19:32 -0700 Subject: [PATCH 4/4] outDir is clearer I suppose --- cmd/extract/extract.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/extract/extract.go b/cmd/extract/extract.go index 998ca7221d..501864dc26 100644 --- a/cmd/extract/extract.go +++ b/cmd/extract/extract.go @@ -30,8 +30,8 @@ import ( func main() { paths := []string{"cmd", "pkg"} functions := []string{"translate.T"} - output := "translations" - err := extract.TranslatableStrings(paths, functions, output) + outDir := "translations" + err := extract.TranslatableStrings(paths, functions, outDir) if err != nil { panic(err)