mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
kubectl: move translations to i18n package to kubectl staging directory
Go 1.16's embed directive doesn't allow embeding files from parent directories. Hence, moving the translations data to inside the i18n package. Logically speaking as well, kubectl related artifacts should be inside the kubectl package. Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
This commit is contained in:
parent
1151dc1ee5
commit
5ece28b77a
@ -21,6 +21,7 @@
|
||||
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"
|
||||
|
||||
generate_pot="false"
|
||||
@ -71,7 +72,7 @@ if [[ "${generate_pot}" == "true" ]]; then
|
||||
perl -pi -e 's/\\\)/\\\\\)/g' tmp.pot
|
||||
kube::util::ensure-temp-dir
|
||||
if msgcat -s tmp.pot > "${KUBE_TEMP}/template.pot"; then
|
||||
mv "${KUBE_TEMP}/template.pot" translations/kubectl/template.pot
|
||||
mv "${KUBE_TEMP}/template.pot" "${TRANSLATIONS}/kubectl/template.pot"
|
||||
rm tmp.pot
|
||||
else
|
||||
echo "Failed to update template.pot"
|
||||
@ -81,12 +82,10 @@ fi
|
||||
|
||||
if [[ "${generate_mo}" == "true" ]]; then
|
||||
echo "Generating .po and .mo files"
|
||||
for x in translations/*/*/*/*.po; do
|
||||
for x in "${TRANSLATIONS}"/*/*/*/*.po; do
|
||||
msgcat -s "${x}" > tmp.po
|
||||
mv tmp.po "${x}"
|
||||
echo "generating .mo file for: ${x}"
|
||||
msgfmt "${x}" -o "$(dirname "${x}")/$(basename "${x}" .po).mo"
|
||||
done
|
||||
fi
|
||||
|
||||
./hack/generate-bindata.sh
|
||||
|
@ -5,7 +5,7 @@ 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
|
||||
Create `staging/src/k8s.io/kubectl/pkg/util/i18n/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](https://github.com/kubernetes/kubernetes/pull/40645) which adds support for French.
|
||||
@ -14,7 +14,7 @@ Once you've added a new language, you'll need to register it in
|
||||
`staging/src/k8s.io/kubectl/pkg/util/i18n/i18n.go` by adding it to the `knownTranslations` map.
|
||||
|
||||
## Wrapping strings
|
||||
There is a simple script in `translations/extract.py` that performs
|
||||
There is a simple script in `staging/src/k8s.io/kubectl/pkg/util/i18n/translations/extract.py` that performs
|
||||
simple regular expression based wrapping of strings. It can always
|
||||
use improvements to understand additional strings.
|
||||
|
||||
@ -31,7 +31,7 @@ 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
|
||||
for translations. You can load the `staging/src/k8s.io/kubectl/pkg/util/i18n/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`
|
||||
@ -55,7 +55,7 @@ binaries.
|
||||
|
||||
## Extracting strings
|
||||
|
||||
There is a script in `translations/extract.py` that knows how to do some
|
||||
There is a script in `staging/src/k8s.io/kubectl/pkg/util/i18n/translations/extract.py` that knows how to do some
|
||||
simple extraction. It needs a lot of work.
|
||||
|
||||
# Using translations
|
Loading…
Reference in New Issue
Block a user