fix update-translations.sh

This commit is contained in:
atiratree 2021-05-17 15:37:36 +02:00
parent 6acc62da75
commit 079d8aeb1e
2 changed files with 16 additions and 6 deletions

View File

@ -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

View File

@ -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