| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Locale::Maketext::Utils::Phrase::Norm::EndPunc; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
4005
|
use strict; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
150
|
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
1629
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub normalize_maketext_string { |
|
7
|
69
|
|
|
69
|
0
|
194
|
my ($filter) = @_; |
|
8
|
|
|
|
|
|
|
|
|
9
|
69
|
|
|
|
|
224
|
my $string_sr = $filter->get_string_sr(); |
|
10
|
|
|
|
|
|
|
|
|
11
|
69
|
100
|
|
|
|
126
|
if ( ${$string_sr} !~ m/[\!\?\.\:\]…]$/ ) { # ? TODO ? smarter check that is is actual bracket notation and not just a string ? |
|
|
69
|
|
|
|
|
400
|
|
|
12
|
8
|
100
|
|
|
|
23
|
if ( !__is_title_case( ${$string_sr} ) ) { |
|
|
8
|
|
|
|
|
36
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ${$string_sr} = ${$string_sr} . "[comment,missing puncutation ?]"; |
|
15
|
4
|
|
|
|
|
22
|
$filter->add_warning('Non title/label does not end with some sort of punctuation or bracket notation.'); |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
69
|
|
|
|
|
241
|
return $filter->return_value; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# this is a really, really, REALLY, *REALLY* dumb check (that is why this filter is a warning) |
|
23
|
|
|
|
|
|
|
sub __is_title_case { |
|
24
|
20
|
|
|
20
|
|
1843
|
my ($string) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
20
|
|
|
|
|
48
|
my $word; # buffer |
|
27
|
20
|
|
|
|
|
46
|
my $possible_ick = 0; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# this splits on the whitespace leftover after the Whitespace filter |
|
30
|
20
|
|
|
|
|
256
|
for $word ( split( /(?:\x20|\xc2\xa0)/, $string ) ) { |
|
31
|
68
|
50
|
33
|
|
|
304
|
next if !defined $word || $word eq ''; # e.g ' … X Y' |
|
32
|
68
|
100
|
|
|
|
275
|
next if $word =~ m/^[A-Z\[]/; # When would a title/label ever start life w/ a beginning ellipsis? i.e. ' … Address' instead of 'Email Address'. |
|
33
|
|
|
|
|
|
|
# If it is a short conclusion it should have puncutaion, e.g. 'Compiling …' ' … done.' |
|
34
|
32
|
100
|
|
|
|
113
|
next if length($word) < 3; # There are longer words that should be lowercase (hint: [asis] [comment]), there are shorter words that should be capitol: see “this is a …” above |
|
35
|
|
|
|
|
|
|
|
|
36
|
20
|
|
|
|
|
45
|
$possible_ick++; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
20
|
100
|
|
|
|
118
|
return if $possible_ick; |
|
40
|
12
|
|
|
|
|
72
|
return 1; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=encoding utf-8 |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 Normalization |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
We want to make sure phrases end correctly and consistently. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 Rationale |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Correct punctuation makes the meaning clearer to end users. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Clearer meaning makes it easier to make a good translation. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Consistent punctuation makes it easier for developers to work with. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Consistent punctuation is a sign of higher quality product. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Missing punctuation is a sign that partial phrases are in use or an error has been made. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 IF YOU USE THIS FILTER ALSO USE … |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
… THIS FILTER L<Locale::Maketext::Utils::Phrase::Norm::Whitespace>. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This is not enforced anywhere since we want to assume the coder knows what they are doing. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 possible violations |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
None |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 possible warnings |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=over 4 |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item Non title/label does not end with some sort of punctuation or bracket notation. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Problem should be self explanatory. Ending punctuation is not !, ?, ., :, bracket notation, or an ellipsis character. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
If it is legit you could address this by adding a [comment] to the end for clarity and to make it harder to use as a partial phrase. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
For some reason I must not end well[comment,no puncuation because …] |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
If it is titlecase and it has word longer than 2 characters that must start with a lower case letter you have 2 options: |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item 1 use asis() |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Buy [asis,aCme™] Products |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item 2 use comment() with a comment that does not have a space or a non-break space: |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
People [comment,this-has-to-start-with-lowercase-because-…]for Love |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 Entire filter only runs under extra filter mode. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
See L<Locale::Maketext::Utils::Phrase::Norm/extra filters> for more details. |