Remmina - The GTK+ Remote Desktop Client  v1.4.33
Remmina is a remote desktop client written in GTK+, aiming to be useful for system administrators and travellers, who need to work with lots of remote computers in front of either large monitors or tiny netbooks. Remmina supports multiple network protocols in an integrated and consistent user interface. Currently RDP, VNC, NX, XDMCP and SSH are supported.
i18nstats.sh
Go to the documentation of this file.
1 #!/bin/bash -
2 #===============================================================================
3 #
4 # FILE: i18nstats.sh
5 #
6 # USAGE: ./i18nstats.sh
7 #
8 # DESCRIPTION:
9 #
10 # OPTIONS: ---
11 # REQUIREMENTS: ---
12 # BUGS: ---
13 # NOTES: ---
14 # AUTHOR: Antenore Gatta (tmow), antenore@simbiosi.org
15 # ORGANIZATION: Remmina
16 # CREATED: 30. 01. 19 00:05:25
17 # LICENSE: GPLv2
18 # REVISION: ---
19 #===============================================================================
20 
21 set -o nounset # Treat unset variables as an error
22 
23 SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
24 REMMINATOP="$(dirname "$SCRIPTPATH")"
25 REMTMPDIR="$(mktemp -d)"
26 REMTMPFILE="$(mktemp -p "$REMTMPDIR")"
27 
28 trap "rm -rf $REMTMPDIR" HUP INT QUIT TERM EXIT
29 
30 declare -x TRANSLATED
31 declare -x UNTRANSLATED
32 declare -x FUZZY
33 
34 #===============================================================================
35 # FUNCTION DEFINITIONS
36 #===============================================================================
37 
38 #-------------------------------------------------------------------------------
39 # TODO: Move these functions in an external library file
40 #-------------------------------------------------------------------------------
41 
42 rem_varhasvalue () {
43  if [[ -n ${!1:-} ]]; then
44  return 0
45  fi
46  return 1
47 
48 } # ---------- end of function rem_varhasvalue ----------
49 
50 rem_varisdefined () {
51  typeset -p ${1:-} >/dev/null 2>&1 # Not portable, bash specific
52 } # ---------- end of function rem_varisdefined ----------
53 
54 rem_log () {
55  local _cmnhead="${HOSTNAME:=$(hostname)}"
56  local _header=""
57  local _message="$*"
58  #local _stdout=""
59  local _msgdate=""
60  case "$1" in
61  CRITICAL)
62  _header="CRITICAL"
63  shift
64  _message="$*"
65  ;;
66  ERROR)
67  _header="ERROR"
68  shift
69  _message="$*"
70  ;;
71  WARNING)
72  _header="WARNING"
73  shift
74  _message="$*"
75  ;;
76  DEBUG)
77  _header="DEBUG"
78  shift
79  _message="$*"
80  ;;
81  INFO)
82  # We can add color support adding colors in the beginning
83  # GREEN="\033[0;32m"
84  # RESET="\033[0m"
85  # _reset=${RESET:-'\033[0m'}
86  # _color=${_reset}
87  #_color=${GREEN}
88  _header="INFO"
89  shift
90  _message="$*"
91  ;;
92  *)
93  _header="INFO"
94  _message="$*"
95  ;;
96  esac
97  if ! rem_varisdefined DFORMAT ; then
98  local _dateformat='%d/%m/%y %H:%M:%S'
99  else
100  local _dateformat=${DFORMAT:-}
101  fi
102  _msgdate="$(date +"$_dateformat")"
103 
104  # printf "%s%s - [%s] - %s - %s%s\n" "$_color" "$_header" "$_msgdate" "${_cmnhead}" "$_message" "$_reset"
105  printf "%s - [%s] - %s - %s\n" "$_header" "$_msgdate" "${_cmnhead}" "$_message"
106 
107 } # ---------- end of function rem_log ----------
108 #-------------------------------------------------------------------------------
109 # rem_which a poorman which function
110 # Return 0 un success or 1 in case of failure
111 rem_which () {
112  local _tool=()
113  local _ret=
114  for _tool in "$@" ; do
115  if type "$_tool" >/dev/null 2>&1 ; then
116  _ret=0
117  else
118  _ret=1
119  fi
120  case $_ret in
121  0)
122  rem_log INFO "$_tool found"
123  ;;
124  1)
125  rem_log ERROR "$_tool not found"
126  ;;
127  esac
128  done
129  unset _tool
130  return "$_ret"
131 } # ---------- end of function rem_which ----------
132 
133 
134 #===============================================================================
135 # MAIN SCRIPT
136 #===============================================================================
137 
138 
139 if ! rem_which "xgettext" "msgmerge" "git" ; then
140  rem_log ERROR "Some tools have not been found"
141  exit 1
142 fi
143 
144 cd "$REMMINATOP"/po || { rem_log ERROR "$REMMINATOP/po not found" ; exit 1 ; }
145 
146 for _pofile in *po ; do
147  printf "%s: " "$_pofile" ; msgfmt --statistics "$_pofile"
148 done >| "$REMTMPFILE" 2>&1
149 
150 TRANSLATED=""
151 FUZZY=""
152 UNTRANSLATED=""
153 MAX=0
154 while IFS= read -r _msgstat ; do
155  #rem_log INFO "dealing with data: $_msgstat"
156  if echo "$_msgstat" | grep '^[a-z@_A-Z]\+\.po:.*\.$' >/dev/null 2>&1 ; then
157  _translated="$(echo "$_msgstat" | sed -e 's/\(^[a-z]\+.*: \)\([0-9]\+\)\( \)\(translated messages\?\)\(.*\.$\)/\2/g')"
158  _fuzzy="$(echo "$_msgstat" | sed -e 's/\(^[a-z]\+.* \)\([0-9]\+\)\( \)\(fuzzy translations\?\)\(.*\.$\)/\2/g')"
159  _untranslated="$(echo "$_msgstat" | sed -e 's/\(^[a-z]\+.* \)\([0-9]\+\)\( \)\(untranslated messages\?\)\(.*\.$\)/\2/g')"
160  case $_translated in
161  ''|*[!0-9]*)
162  _translated=0
163  ;;
164  *)
165  #rem_log INFO "translated: $_translated"
166  ;;
167  esac
168  case $_untranslated in
169  ''|*[!0-9]*)
170  _untranslated=0
171  ;;
172  *)
173  #rem_log INFO "untranslated: $_untranslated"
174  ;;
175  esac
176  case $_fuzzy in
177  ''|*[!0-9]*)
178  _fuzzy=0
179  ;;
180  *)
181  #rem_log INFO "fuzzy: $_fuzzy"
182  ;;
183  esac
184  _pofile="$(echo "$_msgstat" | cut -d: -f1)"
185  #printf "%s %s %s %s\n" "$_pofile" "$_translated" "$_fuzzy" "$_untranslated"
186  _sum=$((_translated + _fuzzy + _untranslated))
187  [[ "$MAX" -lt "$_sum" ]] && MAX="$_sum"
188  # [["0",32],["1",46],["2",28],["3",21],["4",20],["5",13],["6",27]]
189  _tav="$(printf "[\"%s\",%s]," "$_pofile" "$_translated")"
190  TRANSLATED="${TRANSLATED}$_tav"
191  _tav="$(printf "[\"%s\",%s]," "$_pofile" "$_fuzzy")"
192  FUZZY="${FUZZY}$_tav"
193  _tav="$(printf "[\"%s\",%s]," "$_pofile" "$_untranslated")"
194  UNTRANSLATED="${UNTRANSLATED}$_tav"
195  unset _translated _untranslated _fuzzy _tav
196  fi
197 done < "$REMTMPFILE"
198 cat << EOF > "$REMMINATOP"/data/reports/postats.html
199 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
200 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-us">
201  <head>
202  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
203  <meta name="viewport" content="width=device-width, initial-scale=1" />
204  <title>Remmina Translation Status</title>
205  <script type="text/javascript" src="chartkick.min.js"></script>
206  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.js"></script>
207  <script type="text/javascript">
208  Chartkick.CustomChart = function (element, dataSource, options) {
209  };
210  </script>
211  <style type="text/css">
212  body {
213  padding: 20px;
214  margin: 0;
215  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
216  }
217  h1 {
218  text-align: center;
219  }
220  .container-fluid {
221  max-width: 900px;
222  margin-left: auto;
223  margin-right: auto;
224  }
225  #multiple-bar-stacked {
226  height: 750px;
227  }
228  </style>
229  </head>
230  <body>
231  <div class="container-fluid">
232  <h1>Remmina Translation Status</h1>
233  <div id="multiple-bar-stacked"></div>
234  <script type="text/javascript">
235  new Chartkick.BarChart(
236  "multiple-bar-stacked", [
237  { name: "Translated", data: [${TRANSLATED:0:-1}] },
238  { name: "Fuzzy", data: [${FUZZY:0:-1}] },
239  { name: "Untranslated", data: [${UNTRANSLATED:0:-1}] }
240  ],
241  { max: ${MAX}, stacked: true }
242  );
243  </script>
244  <!--#include virtual="howto-i18n.html" -->
245  </div>
246  </body>
247 </html>
248 EOF