Merge pull request #40665 from brendandburns/i18n

Automatic merge from submit-queue (batch tested with PRs 40665, 41094, 41351, 41721, 41843)

Update i18n tools and process.

@fabianofranz @zen @kubernetes/sig-cli-pr-reviews 

This is an update to the translation process based on feedback from folks.

The main changes are:
   * `msgctx` is being removed from the files.
   * String wrapping and string extraction have been separated.
   * More tools from the `gettext` family of tools are being used
   * Extracted strings are being sorted for canonical ordering
   * A `.pot` template has been added.
This commit is contained in:
Kubernetes Submit Queue
2017-02-25 03:56:51 -08:00
committed by GitHub
16 changed files with 4124 additions and 3131 deletions

76
hack/update-translations.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/bash
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
KUBECTL_FILES="pkg/kubectl/cmd/*.go pkg/kubectl/cmd/*/*.go"
generate_pot="false"
generate_mo="false"
while getopts "hf:xg" opt; do
case $opt in
h)
echo "$0 [-f files] [-x] [-g]"
echo " -f <file-path>: Files to process"
echo " -x extract strings to a POT file"
echo " -g sort .po files and generate .mo files"
exit 0
;;
f)
KUBECTL_FILES="${OPTARG}"
;;
x)
generate_pot="true"
;;
g)
generate_mo="true"
;;
\?)
echo "[-f <files>] -x -g" >&2
exit 1
;;
esac
done
if ! which go-xgettext > /dev/null; then
echo 'Can not find go-xgettext, install with:'
echo 'go get github.com/gosexy/gettext/go-xgettext'
exit 1
fi
if ! which msgfmt > /dev/null; then
echo 'Can not find msgfmt, install with:'
echo 'apt-get install gettext'
exit 1
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
fi
if [[ "${generate_mo}" == "true" ]]; then
echo "Generating .po and .mo files"
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