File: patchLokalizeWrapping.sh

package info (click to toggle)
colobot 0.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 415,532 kB
  • sloc: cpp: 129,246; ansic: 8,872; python: 2,158; sh: 672; awk: 91; xml: 35; makefile: 31
file content (58 lines) | stat: -rwxr-xr-x 1,673 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Author : BCE - 1905 - 1906
#
# correction into i18n po files.
#	restablish fake wrapping done by lokalize...
#	checking non existing save
#	preventively creating a save before eventual modifications
#	and removing it if no alteration
#
# Histo
#	V0.1
#		base
#		non treatment for po commented lines
#		...
#	V1.0
#		checking save don't exist => checking non existing save
#		+ trace only for modified files
#	issue : sometimes to launch twice...


#
lg=fr 		# language digramme xx.po

# forcing a save name (v 0.2)
# sav=sav0 # permit indental saves use sav, sav1, sav2, ... (v 0.2)
# for fic in $(find . -name $lg.po |sort) ; do
# 	[[ -e $fic.$sav ]] &&
# 		echo -e "=== $fic.$sav preexist\n\t\t ABANDON"  >&2 &&
# 		exit -1
# done

# autofinding a non used savename	(v 1.0)
echo "Seeking for a non used save name..." >&2
i=0
while : ; do
	j=$i
	sav=sav$i # permit indental saves use sav1, sav2, ...
	nb=$(find . -name $lg.po.$sav -print -quit 2> /dev/null | wc -l)
	[[ $nb -eq 0 ]] && break
	(( ++i ))
done

echo "OK, no save $sav preexist ! => processing saving $lg.po into $lg.po.$sav" >&2
sleep 1

	# -exec echo " == restablishing {} =="  >&2 \; 	\
find . -name $lg.po -type f \
	-exec sed -i.$sav \
		-e '/^[^#]/ s/\\n\([^"]\)/\\n"\n"\1/g'	 \
		-e '/^msgid "[^"]/  N;s/^msgid \("[^\n]\+"\)\n"/msgid ""\n\1\n"/' \
		-e '/^msgstr "[^"]/ N;s/^msgstr \(".\+"\)\n"/msgstr ""\n\1\n"/' \
		-e '/^[^#]/ s/\\n\([^"]\)/\\n"\n"\1/g'	 \
			{} \; \
	-exec bash -c '[[ $(diff {} {}.'$sav' 2>/dev/null | wc -l ) == 0 ]] && rm {}.'$sav' || echo "   cleaning {} !!" >&2' \;

	# note : doubling s/\\n\([^"]\)/../g to cover the case : ".*\\n\\n.*"

echo "!! END $0 !" >&2