k3s/translations
Kubernetes Submit Queue 7720c40cb9
Merge pull request #64773 from MasayaAoyama/add-port-foward-examples
Automatic merge from submit-queue (batch tested with PRs 58690, 64773, 64880, 64915, 64831). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

add port-forward examples for sevice

add port-forward examples for sevice

```
$  kubectl port-forward --help

........
Examples:
  # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
  kubectl port-forward pod/mypod 5000 6000

  # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the
deployment
  kubectl port-forward deployment/mydeployment 5000 6000

  # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the
service
  kubectl port-forward service/myservice 5000 6000

  # Listen on port 8888 locally, forwarding to 5000 in the pod
  kubectl port-forward pod/mypod 8888:5000

  # Listen on a random port locally, forwarding to 5000 in the pod
  kubectl port-forward pod/mypod :5000
........
```



**What this PR does / why we need it**:
add port-forward examples for sevice

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
add port-forward examples for sevice
```
2018-06-20 14:21:14 -07:00
..
kubectl Merge pull request #64773 from MasayaAoyama/add-port-foward-examples 2018-06-20 14:21:14 -07:00
test Update extraction script, sort messages, add .pot file. 2017-02-23 18:53:00 +00:00
BUILD bazel: generate pkg/generated/bindata.go at build time 2018-04-25 09:44:22 -07:00
OWNERS Add OWNERS for translations folder 2018-02-04 23:54:07 -08:00
README.md fix broken link 2017-09-05 11:57:26 +08:00
extract.py Extract a bunch more strings from kubectl 2017-04-06 20:12:50 -07:00

README.md

Translations README

This is a basic sketch of the workflow needed to add translations:

Adding/Updating Translations

New languages

Create translations/kubectl/<language>/LC_MESSAGES/k8s.po. There's no need to update translations/test/... which is only used for unit tests.

There is an example PR here which adds support for French.

Once you've added a new language, you'll need to register it in pkg/kubectl/util/i18n/i18n.go by adding it to the knownTranslations map.

Wrapping strings

There is a simple script in translations/extract.py that performs simple regular expression based wrapping of strings. It can always use improvements to understand additional strings.

Extracting strings

Once the strings are wrapped, you can extract strings from go files using the go-xgettext command which can be installed with:

go get github.com/gosexy/gettext/go-xgettext

Once that's installed you can run ./hack/update-translations.sh, which will extract and sort any new strings.

Adding new translations

Edit the appropriate k8s.po file, poedit is a popular open source tool for translations. You can load the translations/kubectl/template.pot file to find messages that might be missing.

Once you are done with your k8s.po file, generate the corresponding k8s.mo file. poedit does this automatically on save, but you can also run ./hack/update-translations.sh to perform the po to mo translation.

We use the English translation as the msgid.

Regenerating the bindata file

Run ./hack/generate-bindata.sh, this will turn the translation files into generated code which will in turn be packaged into the Kubernetes binaries.

Extracting strings

There is a script in translations/extract.py that knows how to do some simple extraction. It needs a lot of work.

Using translations

To use translations, you simply need to add:

import pkg/i18n
...
// Get a translated string
translated := i18n.T("Your message in english here")

// Get a translated plural string
translated := i18n.T("You had % items", items)

// Translated error
return i18n.Error("Something bad happened")

// Translated plural error
return i18n.Error("%d bad things happened")

Analytics