aboutsummaryrefslogtreecommitdiffhomepage
path: root/markup/pod/live-manual/media/text/bin/find-fuzzy.sh
blob: fca86ce19e55abe82edff5b6ce2e9b76777d2196 (plain)
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
#!/bin/sh

set -e

# Script to assist translators in finding and fixing fuzzy strings in live-manual.

echo ""
echo "There are $(grep -w 'fuzzy' manual/po/*/* | wc -l) fuzzy strings altogether in live-manual."
echo "This script can help you find and fix them. What is your language?."
echo "Type: $(ls -C manual/po) ['a' to see all]['q' to quit]" 

# Editor defaults to vim unless otherwise specified in preferences.

EDITOR="${EDITOR:-vim}"

# Creating the function. Searches 'fuzzy' and offers to open editor to fix them.

Find_fuzzy ()
{
	echo ""
	echo "There are $(grep -w 'fuzzy' manual/po/$ANSWER/* | wc -l) fuzzy strings in your language."
	echo ""

	if [ "$(grep -w 'fuzzy' manual/po/$ANSWER/* | wc -l)" -eq "0" ]
	then
		echo "You may now proceed... please do:"
		echo ""
		echo "  * git add ."
		echo "  * git commit -m \"Your commit message.\""
		echo "  * git push "
		echo ""

		exit 0
	else
		grep -w 'fuzzy' manual/po/$ANSWER/*

		echo ""
		echo "Do you want to launch your text editor to start fixing them? [yes/no]"

		read OPENEDITOR

		case "$OPENEDITOR" in
			y*|Y*)
				$EDITOR $(grep -w 'fuzzy' manual/po/$ANSWER/* | sed 's|:#, fuzzy.*||' | uniq)
				;;

			n*|N*)
				exit 0
				;;

			*)	echo "You didn't type 'yes'. Exiting..."
				exit 0
				;;
		esac
	fi

	exit 0
}

# Languages menu.

read ANSWER

case "$ANSWER" in
	en)
		echo "Nothing to be done, really."
		echo "Translation English-English not implemented yet!"
		;;

	ca|de|es|fr|it|ja|pl|pt_BR|ro)
		Find_fuzzy
		;;

	a)
		grep -w 'fuzzy' manual/po/*/*

		echo ""
		echo "Do you want to launch your text editor to start fixing them? [yes/no]"

		read OPENEDITOR

		case "$OPENEDITOR" in
			y*|Y*)
				$EDITOR $(grep -w 'fuzzy' manual/po/*/* | sed 's|:#, fuzzy.*||' | uniq)
				;;

			n*|N*)
				exit 0
				;;

			*)
				echo "You didn't type 'yes'. Exiting..."
				exit 0
				;;
		esac
		;;

	q)
		exit 0
		;;

	*)
		echo "No language chosen. Exiting..."
		;;
esac