From 079d8aeb1e47f8907aa6d3760424047dccfc8279 Mon Sep 17 00:00:00 2001 From: atiratree Date: Mon, 17 May 2021 15:37:36 +0200 Subject: [PATCH] fix update-translations.sh --- hack/update-translations.sh | 16 +++++++++++++--- .../kubectl/pkg/cmd/set/set_serviceaccount.go | 6 +++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/hack/update-translations.sh b/hack/update-translations.sh index fe4d3700f2c..52f14a9f6ca 100755 --- a/hack/update-translations.sh +++ b/hack/update-translations.sh @@ -22,7 +22,12 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/util.sh" TRANSLATIONS="staging/src/k8s.io/kubectl/pkg/util/i18n/translations" -KUBECTL_FILES="pkg/kubectl/cmd/*.go pkg/kubectl/cmd/*/*.go" +KUBECTL_FILES=() +KUBECTL_DEFAULT_LOCATIONS=( + "pkg/kubectl/cmd" + "staging/src/k8s.io/kubectl/pkg/cmd" +) +KUBECTL_IGNORE_FILES_REGEX="cmd/kustomize/kustomize.go" generate_pot="false" generate_mo="false" @@ -37,7 +42,7 @@ while getopts "hf:xg" opt; do exit 0 ;; f) - KUBECTL_FILES="${OPTARG}" + KUBECTL_FILES+=("${OPTARG}") ;; x) generate_pot="true" @@ -52,6 +57,10 @@ while getopts "hf:xg" opt; do esac done +if [[ ${#KUBECTL_FILES} -eq 0 ]]; then + KUBECTL_FILES+=("${KUBECTL_DEFAULT_LOCATIONS[@]}") +fi + if ! which go-xgettext > /dev/null; then echo 'Can not find go-xgettext, install with:' echo 'go get github.com/gosexy/gettext/go-xgettext' @@ -66,7 +75,8 @@ fi if [[ "${generate_pot}" == "true" ]]; then echo "Extracting strings to POT" - go-xgettext -k=i18n.T "${KUBECTL_FILES}" > tmp.pot + # shellcheck disable=SC2046 + go-xgettext -k=i18n.T $(grep -lr "i18n.T" "${KUBECTL_FILES[@]}" | grep -vE "${KUBECTL_IGNORE_FILES_REGEX}") > tmp.pot perl -pi -e 's/CHARSET/UTF-8/' tmp.pot perl -pi -e 's/\\\(/\\\\\(/g' tmp.pot perl -pi -e 's/\\\)/\\\\\)/g' tmp.pot diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/set/set_serviceaccount.go b/staging/src/k8s.io/kubectl/pkg/cmd/set/set_serviceaccount.go index fe0d5c9c746..02349ea1126 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/set/set_serviceaccount.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/set/set_serviceaccount.go @@ -38,14 +38,14 @@ import ( ) var ( - serviceaccountResources = ` - replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset` + serviceaccountResources = i18n.T(`replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset`) serviceaccountLong = templates.LongDesc(i18n.T(` Update ServiceAccount of pod template resources. Possible resources (case insensitive) can be: - ` + serviceaccountResources)) + + `) + serviceaccountResources) serviceaccountExample = templates.Examples(i18n.T(` # Set Deployment nginx-deployment's ServiceAccount to serviceaccount1