20 if [ "$1" ] && [ ! -f "$1" ] ; then
21 msg
"No input file or file doesn't exist."
25 msgcat
--width=79 "$1" | sponge
"$1"
31 if [ "$HAS_COMPENDIUM" = "1" ] && [ "$COMPENDIUM" ]; then
32 XPARAMS
="-C $COMPENDIUM"
34 BACKUP_FILE
="$1.premerge"
35 if [ -f "$BACKUP_FILE" ] ; then
36 msg
"backup file $BACKUP_FILE exists. Can not do a safe merge. Quitting."
39 cp -a "$1" "$BACKUP_FILE"
40 msg
"Merging '$1' with '$2'"
41 msgmerge
-U $XPARAMS "$1" "$2"
47 if [ -f _data
/compendium.po
] ; then
48 export HAS_COMPENDIUM
=1
49 export COMPENDIUM
="$(pwd)/_data/compendium.po"
51 export HAS_COMPENDIUM
=0
58 local COMPENDIUM_URL
="http://i18n.debian.net/debian-l10n/compendia/po/$POLANG/compendium-$POLANG-LATEST.po"
61 wget
-q -O "$(pwd)/_data/compendium.po" "$COMPENDIUM_URL"
66 unset POURL PACKAGE PODIR_URL SUBDIR SECTION BASE_MATERIAL_URL PO_LOCAL_FILE
68 [ -x "$POCONF" ] && .
"$POCONF" ||
:
70 if [ -z "$PODIR_URL" ] ; then
72 if [ -z "$PACKAGE" ] ; then
74 PACKAGE
=${PACKAGE##*/}
77 if [ -z "$SUBDIR" ] ; then
79 [ "${SUBDIR:0:3}" = "lib" ] || SUBDIR
=${SUBDIR:0:1}
82 if [ -z "$BASE_MATERIAL_URL" ] ; then
83 BASE_MATERIAL_URL
=${BASE_MATERIAL_URL-'http://i18n.debian.net/material'}
86 SECTION
=main
#assume main; for contrib and non-free there should be conf files
88 if [ -z "$PODIR_URL" ] ; then
89 PODIR_URL
="$BASE_MATERIAL_URL/po/unstable/$SECTION/$SUBDIR/$PACKAGE/debian/po"
92 if [ -z "$PO_LOCAL_FILE" ] ; then
93 PO_LOCAL_FILE
="$POLANG.po"
99 get_gz_pot_filename
()
101 links2
-dump "$1" |
grep -o -E "$2_[^_]*_templates\.pot\.gz"
104 get_gz_po_filename
()
106 links2
-dump "$1" |
grep -o -E "$2_[^_]*_$3\.po\.gz"
111 cat >$POCONF <<EOCONF
113 PODIR_URL="$PODIR_URL"
114 BASE_MATERIAL_URL="$BASE_MATERIAL_URL"
116 PO_LOCAL_FILE="$PO_LOCAL_FILE"
120 # get the config status.
123 # - 1 if not configured
124 # - 2 if po not present
125 # An optional parameter specifying the subdirectory can be added
126 po_get_config_status
()
129 [ $# -ge 1 ] && PODIR
="$1" || PODIR
="."
130 if [ -f "$PODIR/$POLANG.po" ] ; then
131 [ -f "$PODIR/$POCONF" ] && return 0 ||
return 1
137 po_check_possible_vcs_po
()
139 po_get_config_status
; POCFGST
=$?
140 if [ $POCFGST -eq 1 ] ; then
141 emsg
"A translation file is present, but it's origin isn't declared via the '$POCONF' file."
142 emsg
"Please create an adequate '$POCONF' file to prevent breakage or losing translations."
143 emsg
" NOTE: Normally this operation should be done automatically or by the coordinator."
144 elif [ $POCFGST -eq 2 ] ; then
145 emsg
"No translation file found."
153 po_check_possible_vcs_po ||
return 1
156 GZ_PO_FILENAME
="$(get_gz_po_filename "$PODIR_URL" "$PACKAGE" "$POLANG")"
157 if [ -z "$GZ_PO_FILENAME" ] ; then
158 emsg
"It seems there is no official $POLANG translation for the package $PACKAGE."
159 emsg
"Maybe the config file ($POCONF) is broken, incorrect or absent?"
160 #emsg "Please run po_new_translation to configure this translation."
164 REMOTE_GZ_URL
="$PODIR_URL/$GZ_PO_FILENAME"
165 wget
-q "$REMOTE_GZ_URL" -O - | gunzip
> "$PO_LOCAL_FILE.remote"
167 if [ ! -f "$PO_LOCAL_FILE" ] ; then
168 mv "$PO_LOCAL_FILE.remote" "$PO_LOCAL_FILE"
169 msg
"No local file was present."
170 msg
"Brought in $PO_LOCAL_FILE from $REMOTE_GZ_URL"
172 if [ ! -f "$POCONF" ] ; then
174 msg
"Config file generated"
178 po_merge
"$PO_LOCAL_FILE" "$PO_LOCAL_FILE.remote"
184 if [ ! -x $
(command -v $1) ] ; then
185 msg
"You do not have the $1 utility. Please install $2."
190 po_make_disambiguated_copy
()
194 if [ -e "$PO_LOCAL_FILE" ]
196 if [ "$PO_LOCAL_FILE" != "$PACKAGE.po" ] ; then
197 cp "$PO_LOCAL_FILE" "$PACKAGE.po"
198 echo "Translation disambiguated as '$PACKAGE.po'. Please remove it after sending it."
201 echo "File is already disambiguated an is the local .po file '$PACKAGE.po'."
202 echo " !!! DO NOT REMOVE IT AFTER SENDING IT !!!"
206 echo "No local file to disambiguate, please run po_refresh to grab the file or"
207 echo "contact the language coordinator for an update."
213 export POCONF
=".poconf"
215 check_command sponge moreutils
216 check_command wget wget
217 check_command msgmerge
gettext
218 check_command msgcat
gettext
219 check_command links2 links2