Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract long strings and make available for translation. #42978

Merged
merged 1 commit into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions hack/update-translations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ fi
if [[ "${generate_pot}" == "true" ]]; then
echo "Extracting strings to POT"
go-xgettext -k=i18n.T ${KUBECTL_FILES} > tmp.pot
msgcat -s tmp.pot > translations/kubectl/template.pot
rm 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
if msgcat -s tmp.pot > /tmp/template.pot; then
mv /tmp/template.pot translations/kubectl/template.pot
rm tmp.pot
else
echo "Failed to update template.pot"
exit 1
fi
fi

if [[ "${generate_mo}" == "true" ]]; then
Expand Down
7,471 changes: 7,059 additions & 412 deletions pkg/generated/bindata.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/kubectl/cmd/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ go_test(
"//pkg/kubectl/resource:go_default_library",
"//pkg/printers:go_default_library",
"//pkg/printers/internalversion:go_default_library",
"//pkg/util/i18n:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/util/term:go_default_library",
"//vendor:github.com/spf13/cobra",
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/annotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var (

` + valid_resources)

annotate_example = templates.Examples(`
annotate_example = templates.Examples(i18n.T(`
# Update pod 'foo' with the annotation 'description' and the value 'my frontend'.
# If the same annotation is set multiple times, only the last value will be applied
kubectl annotate pods foo description='my frontend'
Expand All @@ -94,7 +94,7 @@ var (

# Update pod 'foo' by removing an annotation named 'description' if it exists.
# Does not require the --overwrite flag.
kubectl annotate pods foo description-`)
kubectl annotate pods foo description-`))
)

func NewCmdAnnotate(f cmdutil.Factory, out io.Writer) *cobra.Command {
Expand Down
5 changes: 3 additions & 2 deletions pkg/kubectl/cmd/apiversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util/i18n"
)

var (
apiversions_example = templates.Examples(`
apiversions_example = templates.Examples(i18n.T(`
# Print the supported API versions
kubectl api-versions`)
kubectl api-versions`))
)

func NewCmdApiVersions(f cmdutil.Factory, out io.Writer) *cobra.Command {
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubectl/cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ const (
)

var (
apply_long = templates.LongDesc(`
apply_long = templates.LongDesc(i18n.T(`
Apply a configuration to a resource by filename or stdin.
This resource will be created if it doesn't exist yet.
To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.

JSON and YAML formats are accepted.

Alpha Disclaimer: the --prune functionality is not yet complete. Do not use unless you are aware of what the current state is. See https://issues.k8s.io/34274.`)
Alpha Disclaimer: the --prune functionality is not yet complete. Do not use unless you are aware of what the current state is. See https://issues.k8s.io/34274.`))

apply_example = templates.Examples(`
apply_example = templates.Examples(i18n.T(`
# Apply the configuration in pod.json to a pod.
kubectl apply -f ./pod.json

Expand All @@ -93,7 +93,7 @@ var (
kubectl apply --prune -f manifest.yaml -l app=nginx

# Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file.
kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap`)
kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap`))
)

func NewCmdApply(f cmdutil.Factory, out, errOut io.Writer) *cobra.Command {
Expand Down
11 changes: 6 additions & 5 deletions pkg/kubectl/cmd/apply_set_last_applied.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/util/i18n"
)

type SetLastAppliedOptions struct {
Expand All @@ -58,12 +59,12 @@ type SetLastAppliedOptions struct {
}

var (
applySetLastAppliedLong = templates.LongDesc(`
applySetLastAppliedLong = templates.LongDesc(i18n.T(`
Set the latest last-applied-configuration annotations by setting it to match the contents of a file.
This results in the last-applied-configuration being updated as though 'kubectl apply -f <file>' was run,
without updating any other parts of the object.`)
without updating any other parts of the object.`))

applySetLastAppliedExample = templates.Examples(`
applySetLastAppliedExample = templates.Examples(i18n.T(`
# Set the last-applied-configuration of a resource to match the contents of a file.
kubectl apply set-last-applied -f deploy.yaml

Expand All @@ -72,14 +73,14 @@ var (

# Set the last-applied-configuration of a resource to match the contents of a file, will create the annotation if it does not already exist.
kubectl apply set-last-applied -f deploy.yaml --create-annotation=true
`)
`))
)

func NewCmdApplySetLastApplied(f cmdutil.Factory, out, err io.Writer) *cobra.Command {
options := &SetLastAppliedOptions{Out: out, ErrOut: err}
cmd := &cobra.Command{
Use: "set-last-applied -f FILENAME",
Short: "Set the last-applied-configuration annotation on a live object to match the contents of a file.",
Short: i18n.T("Set the last-applied-configuration annotation on a live object to match the contents of a file."),
Long: applySetLastAppliedLong,
Example: applySetLastAppliedExample,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
11 changes: 6 additions & 5 deletions pkg/kubectl/cmd/apply_view_last_applied.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/util/i18n"
)

type ViewLastAppliedOptions struct {
Expand All @@ -42,25 +43,25 @@ type ViewLastAppliedOptions struct {
}

var (
applyViewLastAppliedLong = templates.LongDesc(`
applyViewLastAppliedLong = templates.LongDesc(i18n.T(`
View the latest last-applied-configuration annotations by type/name or file.

The default output will be printed to stdout in YAML format. One can use -o option
to change output format.`)
to change output format.`))

applyViewLastAppliedExample = templates.Examples(`
applyViewLastAppliedExample = templates.Examples(i18n.T(`
# View the last-applied-configuration annotations by type/name in YAML.
kubectl apply view-last-applied deployment/nginx

# View the last-applied-configuration annotations by file in JSON
kubectl apply view-last-applied -f deploy.yaml -o json`)
kubectl apply view-last-applied -f deploy.yaml -o json`))
)

func NewCmdApplyViewLastApplied(f cmdutil.Factory, out, err io.Writer) *cobra.Command {
options := &ViewLastAppliedOptions{Out: out, ErrOut: err}
cmd := &cobra.Command{
Use: "view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME)",
Short: "View latest last-applied-configuration annotations of a resource/object",
Short: i18n.T("View latest last-applied-configuration annotations of a resource/object"),
Long: applyViewLastAppliedLong,
Example: applyViewLastAppliedExample,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
)

var (
attach_example = templates.Examples(`
attach_example = templates.Examples(i18n.T(`
# Get output from running pod 123456-7890, using the first container by default
kubectl attach 123456-7890

Expand All @@ -53,7 +53,7 @@ var (

# Get output from the first pod of a ReplicaSet named nginx
kubectl attach rs/nginx
`)
`))
)

const (
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubectl/cmd/autoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ import (
)

var (
autoscaleLong = templates.LongDesc(`
autoscaleLong = templates.LongDesc(i18n.T(`
Creates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster.

Looks up a Deployment, ReplicaSet, or ReplicationController by name and creates an autoscaler that uses the given resource as a reference.
An autoscaler can automatically increase or decrease number of pods deployed within the system as needed.`)
An autoscaler can automatically increase or decrease number of pods deployed within the system as needed.`))

autoscaleExample = templates.Examples(`
autoscaleExample = templates.Examples(i18n.T(`
# Auto scale a deployment "foo", with the number of pods between 2 and 10, target CPU utilization specified so a default autoscaling policy will be used:
kubectl autoscale deployment foo --min=2 --max=10

# Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%:
kubectl autoscale rc foo --max=5 --cpu-percent=80`)
kubectl autoscale rc foo --max=5 --cpu-percent=80`))
)

func NewCmdAutoscale(f cmdutil.Factory, out io.Writer) *cobra.Command {
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubectl/cmd/clusterinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ import (
)

var (
longDescr = templates.LongDesc(`
longDescr = templates.LongDesc(i18n.T(`
Display addresses of the master and services with label kubernetes.io/cluster-service=true
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.`)
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.`))

clusterinfo_example = templates.Examples(`
clusterinfo_example = templates.Examples(i18n.T(`
# Print the address of the master and cluster services
kubectl cluster-info`)
kubectl cluster-info`))
)

func NewCmdClusterInfo(f cmdutil.Factory, out io.Writer) *cobra.Command {
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubectl/cmd/clusterinfo_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ func NewCmdClusterInfoDump(f cmdutil.Factory, cmdOut io.Writer) *cobra.Command {
}

var (
dumpLong = templates.LongDesc(`
dumpLong = templates.LongDesc(i18n.T(`
Dumps cluster info out suitable for debugging and diagnosing cluster problems. By default, dumps everything to
stdout. You can optionally specify a directory with --output-directory. If you specify a directory, kubernetes will
build a set of files in that directory. By default only dumps things in the 'kube-system' namespace, but you can
switch to a different namespace with the --namespaces flag, or specify --all-namespaces to dump all namespaces.

The command also dumps the logs of all of the pods in the cluster, these logs are dumped into different directories
based on namespace and pod name.`)
based on namespace and pod name.`))

dumpExample = templates.Examples(`
dumpExample = templates.Examples(i18n.T(`
# Dump current cluster state to stdout
kubectl cluster-info dump

Expand All @@ -71,7 +71,7 @@ var (
kubectl cluster-info dump --all-namespaces

# Dump a set of namespaces to /path/to/cluster-state
kubectl cluster-info dump --namespaces default,kube-system --output-directory=/path/to/cluster-state`)
kubectl cluster-info dump --namespaces default,kube-system --output-directory=/path/to/cluster-state`))
)

func setupOutputWriter(cmd *cobra.Command, defaultWriter io.Writer, filename string) io.Writer {
Expand Down
18 changes: 12 additions & 6 deletions pkg/kubectl/cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const defaultBoilerPlate = `
`

var (
completion_long = templates.LongDesc(`
completion_long = templates.LongDesc(i18n.T(`
Output shell completion code for the specified shell (bash or zsh).
The shell code must be evalutated to provide interactive
completion of kubectl commands. This can be done by sourcing it from
Expand All @@ -60,24 +60,30 @@ var (

$ source $(brew --prefix)/etc/bash_completion

Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2`)
Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2`))

completion_example = templates.Examples(`
completion_example = templates.Examples(i18n.T(`
# Install bash completion on a Mac using homebrew
brew install bash-completion
printf "\n# Bash completion support\nsource $(brew --prefix)/etc/bash_completion\n" >> $HOME/.bash_profile
printf "
# Bash completion support
source $(brew --prefix)/etc/bash_completion
" >> $HOME/.bash_profile
source $HOME/.bash_profile

# Load the kubectl completion code for bash into the current shell
source <(kubectl completion bash)

# Write bash completion code to a file and source if from .bash_profile
kubectl completion bash > ~/.kube/completion.bash.inc
printf "\n# Kubectl shell completion\nsource '$HOME/.kube/completion.bash.inc'\n" >> $HOME/.bash_profile
printf "
# Kubectl shell completion
source '$HOME/.kube/completion.bash.inc'
" >> $HOME/.bash_profile
source $HOME/.bash_profile

# Load the kubectl completion code for zsh[1] into the current shell
source <(kubectl completion zsh)`)
source <(kubectl completion zsh)`))
)

var (
Expand Down
10 changes: 5 additions & 5 deletions pkg/kubectl/cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
)

var (
convert_long = templates.LongDesc(`
convert_long = templates.LongDesc(i18n.T(`
Convert config files between different API versions. Both YAML
and JSON formats are accepted.

Expand All @@ -44,9 +44,9 @@ var (
not supported, convert to latest version.

The default output will be printed to stdout in YAML format. One can use -o option
to change to output destination.`)
to change to output destination.`))

convert_example = templates.Examples(`
convert_example = templates.Examples(i18n.T(`
# Convert 'pod.yaml' to latest version and print to stdout.
kubectl convert -f pod.yaml

Expand All @@ -55,7 +55,7 @@ var (
kubectl convert -f pod.yaml --local -o json

# Convert all files under current directory to latest version and create them all.
kubectl convert -f . | kubectl create -f -`)
kubectl convert -f . | kubectl create -f -`))
)

// NewCmdConvert creates a command object for the generic "convert" action, which
Expand All @@ -82,7 +82,7 @@ func NewCmdConvert(f cmdutil.Factory, out io.Writer) *cobra.Command {
cmdutil.AddValidateFlags(cmd)
cmdutil.AddNonDeprecatedPrinterFlags(cmd)
cmd.Flags().BoolVar(&options.local, "local", true, "If true, convert will NOT try to contact api-server but run locally.")
cmd.Flags().String("output-version", "", "Output the formatted object with the given group version (for ex: 'extensions/v1beta1').")
cmd.Flags().String("output-version", "", i18n.T("Output the formatted object with the given group version (for ex: 'extensions/v1beta1').)"))
cmdutil.AddInclude3rdPartyFlags(cmd)
return cmd
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/cmd/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

var (
cp_example = templates.Examples(`
cp_example = templates.Examples(i18n.T(`
# !!!Important Note!!!
# Requires that the 'tar' binary is present in your container
# image. If 'tar' is not present, 'kubectl cp' will fail.
Expand All @@ -49,7 +49,7 @@ var (
kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar

# Copy /tmp/foo from a remote pod to /tmp/bar locally
kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar`)
kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar`))

cpUsageStr = dedent.Dedent(`
expected 'cp <file-spec-src> <file-spec-dest> [-c container]'.
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubectl/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ type CreateOptions struct {
}

var (
create_long = templates.LongDesc(`
create_long = templates.LongDesc(i18n.T(`
Create a resource by filename or stdin.

JSON and YAML formats are accepted.`)
JSON and YAML formats are accepted.`))

create_example = templates.Examples(`
create_example = templates.Examples(i18n.T(`
# Create a pod using the data in pod.json.
kubectl create -f ./pod.json

# Create a pod based on the JSON passed into stdin.
cat pod.json | kubectl create -f -

# Edit the data in docker-registry.yaml in JSON using the v1 API format then create the resource using the edited data.
kubectl create -f docker-registry.yaml --edit --output-version=v1 -o json`)
kubectl create -f docker-registry.yaml --edit --output-version=v1 -o json`))
)

func NewCmdCreate(f cmdutil.Factory, out, errOut io.Writer) *cobra.Command {
Expand Down