~cairo-dock-team/cairo-dock-plug-ins/plug-ins

« back to all changes in this revision

Viewing changes to po/misc/replace_my_trad.sh

  • Committer: Matthieu Baerts
  • Date: 2014-10-19 00:26:10 UTC
  • Revision ID: matttbe@gmail.com-20141019002610-ulf26s9b4c4rw10r
We just switched from BZR to Git.
Follow us on Github: https://github.com/Cairo-Dock

Note: we will only use Github to manage our source code and all pull requests.
Please continue to report your bugs/ideas/messages on our forum or Launchpad! 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
# on cherche le fichier contenant le string
4
 
COUNT=0
5
 
if [ "$1" = "" ]; then exit; fi
6
 
if [ "$2" = "" ]; then exit; fi
7
 
if [ "$2" = "$1" ]; then exit; fi
8
 
PH1=`echo $1 | sed 's/\\\n/\\\\\\\n/g' | sed 's/\\%/%/g'`
9
 
PH2=`echo $2 | sed 's/\\\n/\\\\\\\n/g' | sed 's/\\%/%/g'`
10
 
PG_check=`pwd | grep -c "plug-ins"` # 0 = core
11
 
if test $PG_check -eq 0; then 
12
 
        FILES_MODIF=`grep -s -r "$PH1" ../src/ -l | grep -v Makefile | grep -v config | grep -v ".bzr" | grep -v "deps" | grep -v "libs" | grep -v depcomp | grep -v "en_temp" | grep -v "sub$" | grep -v "log$" | grep -v "status" | grep -v copyright | grep -v "pc$" | grep -v ChangeLog | grep -v docum | grep -v INSTALL | grep -v "install" | grep -v intltool | grep -v missing | grep -v stamp | grep -v autom4te | grep -v "~$"`
13
 
else
14
 
        FILES_MODIF=`grep -s -r "$PH1" ../*/src/ -l | grep -v Makefile | grep -v config | grep -v ".bzr" | grep -v "deps" | grep -v "libs" | grep -v depcomp | grep -v "en_temp" | grep -v "sub$" | grep -v "log$" | grep -v "status" | grep -v copyright | grep -v "pc$" | grep -v ChangeLog | grep -v docum | grep -v INSTALL | grep -v "install" | grep -v intltool | grep -v missing | grep -v stamp | grep -v autom4te | grep -v "~$"`
15
 
fi
16
 
# double checkcheck
17
 
if [ "$FILES_MODIF" != "" ]; then
18
 
        COUNT=1
19
 
        for i in $FILES_MODIF; do
20
 
                # les .c et .h
21
 
                if test `echo $i | grep -c "\.c$"` -ge 1 -o `echo $i | grep -c "\.h$"` -ge 1; then
22
 
                        if test `grep "$PH1" $i | grep -c "_("` -ge 1; then
23
 
                                sed -i "s/_(\"$PH1\"/_(\"$PH2\"/g" "$i"
24
 
                                if test $? -ge 1; then
25
 
                                        echo "Phrase <$PH1>, donne une erreur ($i)" >> transfert_translations_log_errors_2.txt
26
 
                                fi
27
 
                        fi
28
 
                ## les autres
29
 
                #else
30
 
                #       sed -i "s/$PH1/$PH2/g" "$i"
31
 
                fi
32
 
        done
33
 
fi
34
 
 
35
 
# CONF : retours à la ligne avec des '\n# '
36
 
#ph1=`echo $1 | sed 's/\\\n/\n#/g' | sed 's/\\%/%/g'`
37
 
#ph2=`echo $2 | sed 's/\\\n/\n#/g' | sed 's/\\%/%/g'`
38
 
ph1=`echo $1 | sed 's/\\\n/\\\\\\\n#/g' | sed 's/\\%/%/g'`
39
 
ph2=`echo $2 | sed 's/\\\n/\\\\\\\n#/g' | sed 's/\\%/%/g'`
40
 
if test $PG_check -eq 0; then 
41
 
        DATA_MODIF=`find ../data/ -name "*conf*" -type f -print | grep -v "\.sh$"`
42
 
else
43
 
        DATA_MODIF=`ls ../*/data/*.conf.in`
44
 
fi
45
 
if [ "$DATA_MODIF" != "" ]; then
46
 
        COUNT=1
47
 
        for i in $DATA_MODIF; do
48
 
                sed -i ':z;N;s/\n#/\\n#/;bz' "$i" # => tout sur une ligne
49
 
                # sed -i "s/$ph1/$ph2/g" "$i"
50
 
                sed -i "s/] $ph1/] $ph2/g" "$i"
51
 
                sed -i "s/\[$ph1/\[$ph2/g" "$i"
52
 
                sed -i "s/{$ph1/{$ph2/g" "$i"
53
 
                sed -i "s/+ $ph1/+ $ph2/g" "$i"
54
 
                sed -i "s/- $ph1/- $ph2/g" "$i"
55
 
                sed -i "s/> $ph1/> $ph2/g" "$i"
56
 
                sed -i "s/;$ph1;/;$ph2;/g" "$i"
57
 
                sed -i "s/;$ph1]/;$ph2]/g" "$i"
58
 
                sed -i "s/#b $ph1/#b $ph2/g" "$i"
59
 
                sed -i "s/#B $ph1/#B $ph2/g" "$i"
60
 
                sed -i "s/#c $ph1/#c $ph2/g" "$i"
61
 
                sed -i "s/#C $ph1/#C $ph2/g" "$i"
62
 
                sed -i "s/#k $ph1/#k $ph2/g" "$i"
63
 
                sed -i "s/#s $ph1/#s $ph2/g" "$i"
64
 
                sed -i "s/#s99 $ph1/#s99 $ph2/g" "$i"
65
 
                sed -i "s/#S $ph1/#S $ph2/g" "$i"
66
 
                sed -i "s/#d $ph1/#d $ph2/g" "$i"
67
 
                sed -i "s/#D $ph1/#D $ph2/g" "$i"
68
 
                sed -i "s/#D99 $ph1/#D99 $ph2/g" "$i"
69
 
                sed -i "s/#K $ph1/#K $ph2/g" "$i"
70
 
                sed -i "s/#_ $ph1/#_ $ph2/g" "$i"
71
 
                sed -i "s/#u $ph1/#u $ph2/g" "$i"
72
 
                sed -i "s/#U $ph1/#U $ph2/g" "$i"
73
 
                sed -i "s/#a $ph1/#a $ph2/g" "$i"
74
 
                sed -i "s/#p $ph1/#p $ph2/g" "$i"
75
 
                if test $? -ge 1;then
76
 
                        echo "Phrase Le fichier /opt/cairo-dock_bzr/cairo-dock-core/po/testttt a été modifié sur le disque.<$ph1>, donne une erreur ($i)" >> transfert_translations_log_errors_2.txt
77
 
                fi
78
 
                sed -i 's/\\n#/\n#/g' "$i" # => on remet comme avant
79
 
        done
80
 
fi
81
 
 
82
 
# ChangeLog.txt : retours à la ligne comme les .c/.h
83
 
if [ `pwd | grep -c core` -ge 1 ]; then
84
 
        if [ `grep -c "$PH1" ../data/ChangeLog.txt` -ge 1 ];then
85
 
                COUNT=1
86
 
                sed -i "s/ = $PH1/ = $PH2/g" "../data/ChangeLog.txt"
87
 
                if test $? -ge 1; then
88
 
                        echo "Phrase <$PH1>, donne une erreur (CL)" >> transfert_translations_log_errors_2.txt
89
 
                fi
90
 
        fi
91
 
fi
92
 
 
93
 
if test $COUNT -eq 0; then
94
 
        echo "Erreur pour <$PH1>" >> transfert_translations_log_error.txt
95
 
fi
96
 
 
97
 
# obligatoirement dans les po/pot : retours à la ligne comme les .c/.h
98
 
#Ph1=`echo $1 | sed ':z;N;s/\n/\\n\"\n\"/;bz' | sed 's/\\%/%/g'`
99
 
#Ph2=`echo $2 | sed ':z;N;s/\n/\\n\"\n\"/;bz' | sed 's/\\%/%/g'`
100
 
# pas de g => seulement la 1ere occurence
101
 
for i in `ls *.po`; do
102
 
        sed -i "s/\"$PH1\"/\"$PH2\"/" "$i"
103
 
        if test $? -ge 1; then
104
 
                echo "Phrase <$PH1>, donne une erreur ($i)" >> transfert_translations_log_errors_2.txt
105
 
        fi
106
 
done
107
 
sed -i "s/\"$PH1\"/\"$PH2\"/" "cairo-dock.pot"
108
 
if [ $? -ge 1 ]; then
109
 
        echo "Phrase <$PH1>, donne une erreur (pot)" >> transfert_translations_log_errors_2.txt
110
 
fi