addons-server/locale/omg_new_l10n.sh

147 строки
4.1 KiB
Bash
Исходник Обычный вид История

2013-07-23 02:41:51 +04:00
#! /bin/bash
# This script will do the following:
2013-10-19 00:35:21 +04:00
# - Update your code
# - Extract new strings and push to the .po files
2013-07-23 02:41:51 +04:00
# - Compile all .po files
# - Commit all your changes
2013-10-19 00:35:21 +04:00
# - Email the l10n list
2013-07-23 02:41:51 +04:00
#
# This script makes a lot of assumptions and has no error checking, so read it
# over before you run it.
#
# Questions? Talk to clouserw.
2013-10-19 00:35:21 +04:00
2014-04-09 20:33:03 +04:00
EMAIL_FROM="AMO Developers <amo-developers@mozilla.org>"
2013-10-19 00:35:21 +04:00
EMAIL_TO="Awesome Localizers <dev-l10n-web@lists.mozilla.org>"
2014-03-26 20:19:16 +04:00
EMAIL_SUBJECT="[AMO] .po files updated"
2013-10-19 00:35:21 +04:00
# A link to the .po files
2014-03-26 20:19:16 +04:00
EMAIL_SOURCE="https://github.com/mozilla/olympia/tree/master/locale"
2013-10-19 00:35:21 +04:00
# gettext flags
CLEAN_FLAGS="--no-obsolete --width=200 --add-location=file"
2016-06-21 16:30:42 +03:00
MERGE_FLAGS="--update --width=200 --backup=none"
UNIQ_FLAGS="--width=200"
2013-10-19 00:35:21 +04:00
unset DOALLTHETHINGS
# -------------------------------------------------------------------
2013-07-23 02:41:51 +04:00
function confirm {
2013-10-19 00:35:21 +04:00
if [ ! -z $DOALLTHETHINGS ]; then
return 0
fi
2013-07-23 02:41:51 +04:00
PROMPT=$1
read -p "$PROMPT [y/n]: " YESNO
if [[ $YESNO == 'y' ]]
then
return 0
else
return 1
fi
}
2013-10-19 00:35:21 +04:00
if [[ "$1" == "--do-all-the-things" ]]; then
DOALLTHETHINGS=1
fi
2013-07-23 02:41:51 +04:00
if [ ! -d "locale" ]; then
echo "Sorry, please run from the root of the project, eg. ./locale/omg_new_l10n.sh"
exit 1
fi
#if [ ! -z "$(git status --porcelain)" ]; then
# echo "Looks like you have some local changes. Please clean up your root before we start committing random things."
# git status
# exit 1
#fi
2013-10-19 00:35:21 +04:00
2013-07-23 02:41:51 +04:00
echo "Alright, here we go..."
2016-11-16 19:16:02 +03:00
# ./manage.py extract
pushd locale > /dev/null
echo "Merging any new keys..."
for i in `find . -name "django.po" | grep -v "en_US"`; do
msguniq $UNIQ_FLAGS -o "$i" "$i"
msgmerge $MERGE_FLAGS "$i" "templates/LC_MESSAGES/django.pot"
done
msgen templates/LC_MESSAGES/django.pot | msgmerge $MERGE_FLAGS en_US/LC_MESSAGES/django.po -
2016-11-16 19:16:02 +03:00
# echo "Merging any new javascript keys..."
# for i in `find . -name "djangojs.po" | grep -v "en_US"`; do
# msguniq $UNIQ_FLAGS -o "$i" "$i"
# msgmerge $MERGE_FLAGS "$i" "templates/LC_MESSAGES/djangojs.pot"
# done
# msgen templates/LC_MESSAGES/djangojs.pot | msgmerge $MERGE_FLAGS en_US/LC_MESSAGES/djangojs.po -
echo "Cleaning out obsolete messages. See bug 623634 for details."
for i in `find . -name "django.po"`; do
msgattrib $CLEAN_FLAGS --output-file=$i $i
done
for i in `find . -name "djangojs.po"`; do
msgattrib $CLEAN_FLAGS --output-file=$i $i
done
popd > /dev/null
2016-11-16 19:16:02 +03:00
# podebug --rewrite=unicode locale/templates/LC_MESSAGES/django.pot locale/dbg/LC_MESSAGES/django.po
# podebug --rewrite=unicode locale/templates/LC_MESSAGES/djangojs.pot locale/dbg/LC_MESSAGES/djangojs.po
2016-11-16 19:16:02 +03:00
# msgattrib $CLEAN_FLAGS --output-file=locale/dbg/LC_MESSAGES/django.po locale/dbg/LC_MESSAGES/django.po
# msgattrib $CLEAN_FLAGS --output-file=locale/dbg/LC_MESSAGES/djangojs.po locale/dbg/LC_MESSAGES/djangojs.po
pushd locale > /dev/null
msgfilter -i sr/LC_MESSAGES/django.po -o sr_Latn/LC_MESSAGES/django.po recode-sr-latin
popd > /dev/null
# pushd locale > /dev/null
# ./compile-mo.sh .
# popd > /dev/null
2013-07-23 02:41:51 +04:00
#if confirm "Commit your changes?"; then
# git commit locale -m "Extract/compile script. Today's lucky number is $RANDOM."
# git push mozilla master
#fi
2013-07-23 02:41:51 +04:00
2016-11-16 19:16:02 +03:00
# echo "Calculating changes...."
# pushd locale > /dev/null
# CHANGES=$(cat <<MAIL
# From: $EMAIL_FROM
# To: $EMAIL_TO
# Subject: $EMAIL_SUBJECT
2013-07-23 02:41:51 +04:00
2016-11-16 19:16:02 +03:00
# Hi,
2013-07-23 02:41:51 +04:00
2016-11-16 19:16:02 +03:00
# I am an automated script letting you know some .po files have just been
# updated. Unless something unusual is happening, we do weekly pushes on
# Tuesdays so any strings committed by then will go live. To give you an idea of
# the number of new strings I will calculate untranslated strings below.
2013-07-23 02:41:51 +04:00
2016-11-16 19:16:02 +03:00
# `./stats-po.sh .`
2013-07-23 02:41:51 +04:00
2016-11-16 19:16:02 +03:00
# Source files: $EMAIL_SOURCE
2013-07-23 02:41:51 +04:00
2016-11-16 19:16:02 +03:00
# If you have any questions please reply to the list.
2013-07-23 02:41:51 +04:00
2016-11-16 19:16:02 +03:00
# Thanks so much for all your help!
2013-07-23 02:41:51 +04:00
2016-11-16 19:16:02 +03:00
# MAIL
# )
# popd > /dev/null
2013-07-23 02:41:51 +04:00
2016-11-16 19:16:02 +03:00
# echo "-----------------------------------------------"
# echo "$CHANGES"
# echo "-----------------------------------------------"
2013-07-23 02:41:51 +04:00
# Uses sendmail so we can set a real From address
#if confirm "Do you want to send that to $EMAIL_TO?"; then
# echo "$CHANGES" | /usr/lib/sendmail -t
#fi
2013-07-23 02:41:51 +04:00
2013-10-19 00:35:21 +04:00
unset DOALLTHETHINGS
2013-07-23 02:41:51 +04:00
echo "done."