forked from uyuni-project/uyuni-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_localizable
executable file
·35 lines (29 loc) · 1015 Bytes
/
check_localizable
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
#!/bin/sh
#
# SPDX-FileCopyrightText: 2024 SUSE LLC
#
# SPDX-License-Identifier: Apache-2.0
res=0
grep -r . --include '*.go' --exclude '*_test.go' --exclude-dir='vendor' -n \
-e 'fmt\.Errorf("[^"]\+"' \
-e 'errors.New("[^"]\+"' \
-e '\(Fatal\|Error\|Info\|Warn\)()\(\.Err(err)\)\?\.Msgf\?("' \
-e '\.Flags()\.\(String\|Int\|Bool\)\(Slice\)\?\(Var\)\?P\?([^)]\+, \+"[^"]\+")' \
-e '\(Short\|Long\|Title\): \+["`]'
if test $? -eq 0; then
echo -e "Fix the non localizable strings\n"
res=1
fi
grep -r . --include '*.go' --exclude '*_test.go' --exclude-dir='vendor' -n \
-e '\(Trace\|Debug\)()\(\.Err(err)\)\?\.Msgf\?(P\?N\?L("' \
if test $? -eq 0; then
echo -e "Trace and debug messages shouldn't be localizable\n"
res=1
fi
grep -r . --include '*.go' --exclude '*_test.go' --exclude-dir='vendor' -n \
-e '\(Short\|Long\): \+P\?N\?L(["`][a-z]'
if test $? -eq 0; then
echo -e "Short and Long messages shouldn't start with a lowercase letter\n"
res=1
fi
exit $res