File: untranslated-text.sh

package info (click to toggle)
geeqie 1%3A2.5-8
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 16,780 kB
  • sloc: cpp: 110,189; xml: 11,497; sh: 3,681; awk: 124; perl: 88; python: 80; makefile: 23
file content (290 lines) | stat: -rwxr-xr-x 5,995 bytes parent folder | download
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/bin/sh

#**********************************************************************
# Copyright (C) 2024 - The Geeqie Team
#
# Author: Colin Clark
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#**********************************************************************

## @file
## @brief Locate strings not marked for translation
##
## The check is not comprehensive - the exclusions make this
## of limited value.
##
## @FIXME Strings starting with a space, or a lower-case alpha
## or if there is more than one string per line, are not
## checked for.
##
## The regex search is for a character sequence: \n
## double quotes \n
## upper-case alpha character \n
## alpha character or space \n
## printable character \n
## previous character type repeated one or more times \n
## double quotes
##
## The above sequence preceded by "_(" will not be a hit.
##
## $1 file to process
##

TARGET_FILENAME="$1"

# Lines containing these strings will not be checked for untranslated text.
# Only double-quotes should be escaped.
omit_text_array="
 msg
#define
#include
&lt
@brief
@param
COPYRIGHT
ColorSpace
DEBUG
Damien
ERR
EXIF
Error
Exif.
FIXME
ImageLoaderType
LUA_
MonoSpace
N_(
NikonTag
Pause
PixbufRenderer
PluginsMenu
READ_
Separator
WRITE_
Wrap
\"Desktop\"
\"Layout\"
\"OK\"
\"Xmp.
.html
/*
//
{\"
_attribute
action_group
courier
exif_get_item
filter_add_if_missing
font_name
g_ascii_strcasecmp
g_build_filename
g_critical
g_key_file_get_
g_message
g_object
g_signal
g_str_has_suffix
g_strstr_len
g_themed_icon_new
g_warning
getenv
gtk_action_group_get_action
gtk_container_child_get
gtk_widget_add_accelerator
layout_actions
layout_toolbar_add
luaL_
lua_
memcmp
mouse_button_
options->
osd_template_insert
pango_attr
path_to_utf8
primaries_name
print_term
printf
return g_strdup
runcmd
setenv
signal_
signals_
strcmp
strncmp
trc_name
website-label
write_char_option

##cellrendericon.cc
\"Background color as a GdkRGBA\",
\"Background color\",
\"Background set\",
\"Draw focus indicator\",
\"Fixed height\",
\"Fixed width\",
\"Focus\",
\"Foreground color as a GdkRGBA\",
\"Foreground color\",
\"Foreground set\",
\"GQvCellRendererIcon\",
\"Height of icon excluding text\",
\"Marks bit array\",
\"Marks\",
\"Number of marks\",
\"Pixbuf Object\",
\"Show marks\",
\"Show text\",
\"Text to render\",
\"Text\",
\"The pixbuf to render\",
\"Toggled mark\",
\"Whether the marks are displayed\",
\"Whether the text is displayed\",
\"Whether this tag affects the background color\",
\"Whether this tag affects the foreground color\",
\"Width of cell\",

##pixbuf-renderer.cc
\"Delay image update\",
\"Display cache size MiB\",
\"Expand image in autozoom.\",
\"Fit window to image size\",
\"Image actively loading\",
\"Image rendering complete\",
\"Limit size of image when autofitting\",
\"Limit size of parent window\",
\"New image scroll reset\",
\"Number of tiles to retain in memory at any one time.\",
\"Size increase limit of image when autofitting\",
\"Size limit of image when autofitting\",
\"Size limit of parent window\",
\"Tile cache count\",
\"Zoom maximum\",
\"Zoom minimum\",
\"Zoom quality\",

##print.cc
G_CALLBACK(print_set_font_cb), const_cast<char *>(\"Image text font\"));
G_CALLBACK(print_set_font_cb), const_cast<char *>(\"Page text font\"));

##remote.cc
render_intent = g_strdup(\"Absolute Colorimetric\");
render_intent = g_strdup(\"Absolute Colorimetric\");
render_intent = g_strdup(\"Perceptual\");
render_intent = g_strdup(\"Relative Colorimetric\");
render_intent = g_strdup(\"Saturation\");
"

exclude_files_array="
exif.cc
format-canon.cc
format-fuji.cc
format-nikon.cc
format-olympus.cc
keymap-template.cc
bar-keywords.cc
"

# A POSIX-compliant function that returns 0 if the substring is present, or 1
# otherwise.  See https://stackoverflow.com/a/229585
string_contains_substring()
{
	haystack="$1"
	needle="$2"

	case "$haystack" in
		*"$needle"*)
			return 0
			;;
		*)
			return 1
			;;
	esac
}

# Small self-test
if (string_contains_substring "alpha" "bet") || \
	(string_contains_substring "bet" "alphabet") || \
	(string_contains_substring "b*t" "bet")
then
	echo "Negative substring self-test failed."
	exit 1
fi
if ! (string_contains_substring "alphabet" "bet") || \
	! (string_contains_substring "(alpha)(bet)" "bet)")
then
	echo "Positive substring self-test failed."
	exit 1
fi

filename_printed="no"

omit="FILE_OK"
while read -r omit_file
do
	if [ -n "$omit_file" ]
	then
		if string_contains_substring "$TARGET_FILENAME" "$omit_file"
		then
			omit="omit"
		fi
	fi
done << EOF
$exclude_files_array
EOF

if [ "$omit" = "FILE_OK" ]
then
	while read -r infile_line
	do
		if [ -n "$infile_line" ]
		then
			omit="LINE_NOT_OK"
			while read -r omit_text
			do
				if [ -n "$omit_text" ]
				then
					if string_contains_substring "$infile_line" "$omit_text"
					then
						omit="omit"
					fi
				fi
			done << EOF
$omit_text_array
EOF
			if [ "$omit" = "LINE_NOT_OK" ]
			then
				if [ "$filename_printed" = "no" ]
				then
					printf "\nfile: %s\n" "$TARGET_FILENAME"
					filename_printed="yes"
				fi

				no_tabs=$(echo "$infile_line" | tr -s '\t')
				printf "line: %s\n" "$no_tabs"
			fi
		fi
	done << EOF
$(cat --number "$TARGET_FILENAME" | grep --perl-regexp '(?<!_\()"[[:upper:]]([[:lower:]]|[[:space:]])[[:print:]]+"')
EOF
fi

if [ "$filename_printed" = "yes" ]
then
	exit 1
else
	exit 0
fi