forked from linuxmint/cinnamon-spices-desklets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cinnamon-spices-makepot
executable file
·142 lines (133 loc) · 4.72 KB
/
cinnamon-spices-makepot
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
function usage {
echo "Usage:"
echo ""
echo "./cinnamon-spices-makepot ARGUMENT [-i | -r]"
echo ""
echo "Examples:"
echo ""
echo "./cinnamon-spices-makepot [email protected]"
echo "./cinnamon-spcies-makepot [email protected] -i"
echo ""
echo "Options:"
echo ""
echo "-i, --install - Compiles and installs any .po files contained in a spices po folder."
echo " Use this option to test your translations locally before uploading"
echo " to Spices."
echo ""
echo "-r, --remove - The opposite of install, removes translations from the store."
echo ""
echo "-h, --help - Shows the usage of this script."
echo ""
echo "ARGUMENT required:"
echo ""
echo " UUID - The spices UUID."
echo " What it does: Updates the .pot file of UUID."
echo " If .pot file does not exist, it will be created."
echo " Updating a .pot file is done:"
echo " * by running a custom makepot script in UUID/files/UUID/po"
echo " * or else with the command: cinnamon-json-makepot --js"
echo ""
echo " spices-without-pot - Lists all spices, which do not have a .pot file"
}
function makePotFile {
# change directory to UUID/files/UUID
cd $1/files/$1
# check if xlet has a makepot file
if [ -f "po/makepot" ]; then
if [ $2 != "doNotUpdatePotFiles" ]; then
cd po
echo "------------------------------------------------------------------------------------------------------"
echo "$1: po/makepot"
echo "------------------------------------------------------------------------------------------------------"
./makepot
echo ""
cd ..
fi
# generate .pot with default parameters
else
if [ -d po ]; then
potName=$(ls po | grep .pot) # get name of .pot file
else
potName=""
fi
if [ -f "po/$potName" ]; then
if [ $2 != "doNotUpdatePotFiles" ]; then
echo "------------------------------------------------------------------------------------------------------"
echo "$1: cinnamon-json-makepot --js po/$potName (update)"
echo "------------------------------------------------------------------------------------------------------"
cinnamon-json-makepot --js po/$potName
echo ""
fi
else
if [ $2 == "createNewPotFile" ]; then
if [ ! -d po ]; then
mkdir po
fi
echo "------------------------------------------------------------------------------------------------------"
echo "$1: cinnamon-json-makepot --js po/$1.pot (new file)"
echo "------------------------------------------------------------------------------------------------------"
cinnamon-json-makepot --js po/$1.pot
echo ""
elif [ $2 == "doNotUpdatePotFiles" ]; then
echo "$1: has no .pot file"
fi
fi
fi
# change directory back
cd ../../..
}
if [ $# -eq 1 ]; then
# print help
if [ $1 == "-h" ] || [ $1 == "--help" ]; then
usage
exit 1
fi
# if given parameter is 'cinnamon-spices', update .pot files for all xlets
if [ $1 == "cinnamon-spices" ]; then
for uuid in *; do
if [ -d $uuid ]; then
makePotFile $uuid doNotCreateNewPotFiles
fi
done
exit 1
# if given parameter is 'spices-without-pot', print spices, which have no .pot file
elif [ $1 == "spices-without-pot" ]; then
for uuid in *; do
if [ -d $uuid ]; then
makePotFile $uuid doNotUpdatePotFiles
fi
done
exit 1
fi
fi
# install/remove .po files
if [ $# -eq 2 ]; then
if [ -d $1 ]; then
if [ $2 == "-i" ] || [ $2 == "--install" ] || [ $2 == "-r" ] || [ $2 == "--remove" ]; then
# change directory to UUID/files/UUID
cd $1/files/$1
cinnamon-json-makepot $2
exit 1
else
echo "Available options: --install | -i, --remove | -r"
echo "More infos:"
echo ""
echo "./cinnamon-spices-makepot --help"
exit 1
fi
else
echo "UUID $1 does not exist!"
fi
fi
# update .pot file of given xlet UUID
if [ $# -eq 1 ]; then
if [ -d $1 ]; then
makePotFile $1 createNewPotFile
else
echo "Spice with UUID »$1« does not exist!"
fi
exit 1
else
usage
fi