Translate common-rst separately

To ease translation, translate common-rst in a separate po file.
Since we reuse the file in all RST guides, this needs special handling.

common-rst.pot is empty for now, we need the file so that the tools
work.

Change-Id: I9972e6222d4018b238da9b2b8f4e93e6ebc9e224
Co-Authored-By: KATO Tomoyuki <kato.tomoyuki@jp.fujitsu.com>
This commit is contained in:
Andreas Jaeger 2015-06-17 16:19:01 +02:00
parent 823d2b4d02
commit b11e9ef8cc
4 changed files with 51 additions and 5 deletions

View File

@ -84,3 +84,10 @@ minimum_perc = 75
source_file = doc/user-guide-admin/source/locale/user-guide-admin.pot
source_lang = en
type = PO
[openstack-manuals-i18n.common-rst]
file_filter = doc/common-rst/source/locale/<lang>/LC_MESSAGES/common-rst.po
minimum_perc = 75
source_file = doc/common-rst/source/locale/common-rst.pot
source_lang = en
type = PO

View File

@ -29,8 +29,9 @@ POM_FILE="doc/pom.xml"
# Location of doc dir
DOC_DIR="doc/"
# Books with special handling
# Values need to match content in project-config/jenkins/scripts/common_translation_update.sh
# Books with special handling.
# Values need to match content in
# project-config/jenkins/scripts/common_translation_update.sh
declare -A SPECIAL_BOOKS=(
["user-guide"]="RST"
["user-guide-admin"]="RST"
@ -39,4 +40,6 @@ declare -A SPECIAL_BOOKS=(
["admin-guide-cloud-rst"]="skip"
# Skip guide while it's moved to RST.
["install-guide-rst"]="skip"
# This needs special handling, handle it with the RST tools.
["common-rst"] = "RST"
)

View File

@ -12,9 +12,6 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Copy files from trunk to named branch and replace all links from
# trunk with links to the branch
DOCNAME=$1
@ -23,13 +20,52 @@ if [ -z "$DOCNAME" ] ; then
exit 1
fi
# We're not doing anything for this directory. But we need to handle
# it by this script so that the common-rst.pot file gets registered.
if [[ "$DOCNAME" = "common-rst" ]] ; then
exit 0
fi
# Build Glossary
tools/glossary2rst.py doc/common-rst/glossary.rst
# First remove the old pot file, otherwise the new file will contain
# old references
rm -f doc/$DOCNAME/source/locale/$DOCNAME.pot
sphinx-build -b gettext doc/$DOCNAME/source/ doc/$DOCNAME/source/locale/
# Update common
sed -i -e 's/^"Project-Id-Version: [a-zA-Z0-9\. ]+\\n"$/"Project-Id-Version: \\n"/' \
doc/$DOCNAME/source/locale/common.pot
# Create the common pot file
msgcat --sort-output doc/common-rst/source/locale/common-rst.pot \
doc/$DOCNAME/source/locale/common.pot | \
sed -e 's/^"Project-Id-Version: [a-zA-Z0-9\. ]+\\n"$/"Project-Id-Version: \\n"/' | \
awk '$0 !~ /^\# [a-z0-9]+$/' | awk '$0 !~ /^\# \#-\#-\#-\#-\# /' \
> doc/$DOCNAME/source/locale/common-rst.pot
mv -f doc/$DOCNAME/source/locale/common-rst.pot doc/common-rst/source/locale/common-rst.pot
rm -f doc/$DOCNAME/source/locale/common.pot
# Simplify metadata
rm -f doc/common-rst/source/locale/dummy.po
cat << EOF > doc/common-rst/source/locale/dummy.po
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-01-01 01:01+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
EOF
msgmerge -N doc/common-rst/source/locale/dummy.po \
doc/common-rst/source/locale/common-rst.pot > doc/common-rst/source/locale/tmp.pot
mv -f doc/common-rst/source/locale/tmp.pot doc/common-rst/source/locale/common-rst.pot
rm -f doc/common-rst/source/locale/dummy.po
# Take care of deleting all temporary files so that git add
# doc/$DOCNAME/source/locale will only add the single pot file.
# Remove UUIDs, those are not necessary and change too often