This file is indexed.

/usr/lib/perl5/Xacobeo/I18n.pm is in xacobeo 0.13-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
package Xacobeo::I18n;

=head1 NAME

Xacobeo::I18n - Utilities for internationalization (i18n).

=head1 SYNOPSIS

	# Initialize the i18n framework (done once)
	use FindBin;
	use Xacobeo::I18n;
	Xacobeo::I18n->init("$FindBin::Bin/../share/locale/");
	
	
	# Import the i18n utilities (used everywhere where i18n is needed)
	use Xacobeo::I18n;
	print __("Hello world"), "\n";

=head1 DESCRIPTION

This package provides utilities that perform i18n. This module relies on
gettext.

The initialization of the i18n framework should be performed only once,
preferably as soon as possible. Once the framework is initialized any module
requiring to translate a string can include this module.

This module exports automatically the shortcut functions used for translating
messages. This is done in order to make the translation transparent.

=head1 FUNCTIONS

The following functions are available:

=cut

use strict;
use warnings;

use XML::LibXML;
use Locale::Messages qw(dgettext dngettext textdomain bindtextdomain);
use Encode qw(decode);

use Exporter 'import';
our @EXPORT = qw(
	__
	__x
	__n
	__nx
	__xn
);


# The text domain of the application.
my $DOMAIN = 'xacobeo';



=head2 __

Translates a single string through gettext.

Parameters:

=over

=item * $string

The string to translate.

=back

=cut

sub __ {
	my ($msgid) = @_;
	return dgettext_utf8($msgid);
}



=head2 __x

Translates a string that uses place holders for variable substitution.

Parameters:

=over

=item * $string

The string to translate.

=item * %values

A series of key/value pairs that will be replacing the place holders.

=back

=cut

sub __x {
	my ($msgid, %args) = @_;
	my $i18n = dgettext_utf8($msgid);
	return expand($i18n, %args);
}



=head2 __n

Translates a string in either singular or plural.

Parameters:

=over

=item * $singular

The string in its singular form (one item).

=item * $plural

The string in its plural form (more than one item).

=item * $count

The number of items.

=item * %values

A series of key/value pairs that will be replacing the place holders.


=back

=cut

sub __n {
	my ($msgid, $msgid_plural, $count) = @_;
	my $i18n = dngettext_utf8($msgid, $msgid_plural, $count);
	return $i18n;
}



=head2 __nx

Translates a string in either singular or plural with variable substitution.

Parameters:

=over

=item * $singular

The string in its singular form (one item).

=item * $plural

The string in its plural form (more than one item).

=item * $count

The number of items.

=back


=cut

sub __nx {
	my ($msgid, $msgid_plural, $count, %args) = @_;
	my $i18n = dngettext_utf8($msgid, $msgid_plural, $count);
	return expand($i18n);
}



=head2 __xn

Same as L</__nx>.

Parameters:

=over

=item * $singular

The string in its singular form (one item).

=item * $plural

The string in its plural form (more than one item).

=item * $count

The number of items.

=back


=cut

sub __xn {
	my ($msgid, $msgid_plural, $count, %args) = @_;
	return __nx($msgid, $msgid_plural, $count, %args);
}



=head2 domain

Returns the translation domain.

=cut

sub domain {
	return $DOMAIN;
}



#
# Replaces the place markers with their corresponding values.
#
sub expand {
	my ($i18n, %args) = @_;
	my $re = join q{|}, map { quotemeta $_ } keys %args;
	$i18n =~ s{
		[{] ($re) [}] # capture expressions in literal curlies
	}{
		defined $args{$1} ? $args{$1} : "{$1}"
	}egmsx; # and replace all
	return $i18n;
}



#
# Calls dgettext and ensures that the converted text is in UTF-8.
#
sub dgettext_utf8 {
	my ($msgid) = @_;
	my $i18n = dgettext($DOMAIN, $msgid);
	return decode('UTF-8', $i18n);
}



#
# Calls dngettext and ensures that the converted text is in UTF-8.
#
sub dngettext_utf8 {
	my ($msgid, $msgid_plural, $count) = @_;
	my $i18n = dngettext($DOMAIN, $msgid, $msgid_plural, $count);
	return decode('UTF-8', $i18n);
}



=head2 init

Initializes the i18n framework (gettext). Must be called in the fashion:

	Xacobeo::I18n->init($folder);

Parameters:

=over

=item * $folder

The folder where to find the translation files. For instance for the translation
F</usr/share/locale/fr/LC_MESSAGES/xacobeo.mo> the folder F</usr/share/locale>
has to be provided.

=back

=cut

sub init {
	my (undef, $folder) = @_;

	textdomain($DOMAIN);
	bindtextdomain($DOMAIN, $folder);

	return;
}


# A true value
1;


=head1 AUTHORS

Emmanuel Rodriguez E<lt>potyl@cpan.orgE<gt>.

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2008,2009 by Emmanuel Rodriguez.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.

=cut