| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Locale::Maketext::Utils::Phrase::cPanel; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
154729
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
93
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
238
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$Locale::Maketext::Utils::Phrase::cPanel::VERSION = '0.1'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
755
|
use Locale::Maketext::Utils::Phrase::Norm (); |
|
|
2
|
|
|
|
|
32
|
|
|
|
2
|
|
|
|
|
77
|
|
|
9
|
2
|
|
|
2
|
|
17
|
use base 'Locale::Maketext::Utils::Phrase::Norm'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
389
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Mock Cpanel::Locale-specific bracket notation methods for the filters’ default maketext object: |
|
12
|
2
|
|
|
2
|
|
1408
|
use Locale::Maketext::Utils::Mock (); |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
511
|
|
|
13
|
|
|
|
|
|
|
Locale::Maketext::Utils::Mock->create_method( |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
|
|
|
|
|
|
'output_cpanel_error' => undef, |
|
16
|
|
|
|
|
|
|
'get_locale_name_or_nothing' => undef, |
|
17
|
|
|
|
|
|
|
'get_locale_name' => undef, |
|
18
|
|
|
|
|
|
|
'get_user_locale_name' => undef, |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new_legacy_source { |
|
23
|
3
|
50
|
|
3
|
1
|
3532
|
my $conf = ref( $_[-1] ) eq 'HASH' ? pop(@_) : {}; |
|
24
|
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
18
|
$conf->{'exclude_filters'}{'Ampersand'} = 1; |
|
26
|
3
|
|
|
|
|
8
|
$conf->{'exclude_filters'}{'Markup'} = 1; |
|
27
|
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
9
|
push @_, $conf; |
|
29
|
3
|
|
|
|
|
19
|
goto &Locale::Maketext::Utils::Phrase::Norm::new_source; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new_legacy_target { |
|
33
|
3
|
50
|
|
3
|
1
|
5333
|
my $conf = ref( $_[-1] ) eq 'HASH' ? pop(@_) : {}; |
|
34
|
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
16
|
$conf->{'exclude_filters'}{'Ampersand'} = 1; |
|
36
|
3
|
|
|
|
|
11
|
$conf->{'exclude_filters'}{'Markup'} = 1; |
|
37
|
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
10
|
push @_, $conf; |
|
39
|
3
|
|
|
|
|
16
|
goto &Locale::Maketext::Utils::Phrase::Norm::new_target; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# If they ever diverge we simply need to: |
|
43
|
|
|
|
|
|
|
# 1. Update POD |
|
44
|
|
|
|
|
|
|
# 2. probably update t/08.cpanel_norm.t |
|
45
|
|
|
|
|
|
|
# 3. add our own new_source() or list of defaults that SUPER::new_source would call instead of using its array or something |
|
46
|
|
|
|
|
|
|
# sub new_source { |
|
47
|
|
|
|
|
|
|
# … |
|
48
|
|
|
|
|
|
|
# return $_[0]->SUPER::new_source(… @non_default_list …); |
|
49
|
|
|
|
|
|
|
# } |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding utf-8 |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Locale::Maketext::Utils::Phrase::cPanel - cPanel recipe to Normalize and perform lint-like analysis of phrases |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This document describes Locale::Maketext::Utils::Phrase::cPanel version 0.1 |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use Locale::Maketext::Utils::Phrase::cPanel; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $norm = Locale::Maketext::Utils::Phrase::cPanel->new_source() || die; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $result = $norm->normalize('This office has worked [quant,_1,day,days,zero days] without an “accident”.'); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# process $result |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Exactly like L<Locale::Maketext::Utils::Phrase::Norm> except the default filters are what cPanel requires. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DEFAULT cPanel RECIPE FILTERS |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Currently the same as the base class’s L<Locale::Maketext::Utils::Phrase::Norm/"DEFAULT FILTERS">. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
If that ever changes it will be reflected here. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 Legacy related methods |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head3 new_legacy_source() |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Just like L<base new_source()|Locale::Maketext::Utils::Phrase::Norm/"new_source()"> except it skips the markup filters since legacy values can contain HTML. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head3 new_legacy_target() |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Just like L<base new_target()|Locale::Maketext::Utils::Phrase::Norm/"new_target()"> except it skips the markup filters since legacy values can contain HTML. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 Internal Object |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
When a filter needs an object (e.g. Compiles) this module uses a L<Locale::Maketext::Utils::Mock> object that knows about cPanel specific bracket notation methods instead of a Cpanel::Locale object for a number of reasons: |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item 1 Availability |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Things outside of cPanel code (i.e. systems without access to Cpanel::) will have access to the same code that is used on cPanel servers. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
For example: cplint, build servers, QA servers, translators, my laptop, etc |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item 2 Consistency. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Every consumer (including /ULC code, cplint, build servers, QA servers, translators, my laptop, etc) will get the exact same results. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item 3 Sanity check. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Adding new bracket notation needs done thoughtfully and completely. Requiring it be discussed/vetted and then added upstream (i.e. here) helps ensure that that happens. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 4 |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * Does it really belong as bracket notation? |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
There is a good chance there is already a way to do what you want or that it belongs elsewhere. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * If so, is it cPanel specific or should it be in L::M::U ? |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * In addition to tests and it’s Javascript counterpart: |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=over 4 |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * It needs documented in the correct places. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
If its not in L::M::U (i.e. it’s POD) then it needs added to our internal and/or public documentation. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * XLIFF needs to know about it. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
That is true whether it is in L::M::U or C::L. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * The security team will want to review it and add it to their list. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
That is true whether it is in L::M::U or C::L. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
If all of that is satisifed then we add it here and update our RPM and we know we have a solid, well thought out, and well executed new bracket notation method. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
All of those benefits in a process that takes a matter of hours from start to finish. If 24 hours seems too long of a delay compare that to the effort required to undo/deprecate/backcompat a poorly planned/implemented thing! |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Daniel Muey C<< <http://drmuey.com/cpan_contact.pl> >> |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Copyright (c) 2012 cPanel, Inc. C<< <copyright@cpanel.net>> >>. All rights reserved. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
|
158
|
|
|
|
|
|
|
the same terms as Perl itself, either Perl version 5.10.1 or, at your option, |
|
159
|
|
|
|
|
|
|
any later version of Perl 5 you may have available. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
|
164
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
|
165
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
|
166
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
|
167
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
168
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
|
169
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
|
170
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
|
171
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
174
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
175
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
|
176
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
|
177
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
|
178
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
|
179
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
|
180
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
|
181
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
182
|
|
|
|
|
|
|
SUCH DAMAGES. |