/usr/share/perl5/EB/Locale.pm is in eekboek 2.00.03-1.
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 | #! perl -- -*- coding: utf-8 -*-
use utf8;
# Locale.pm -- EB Locale setup (core version)
# RCS Info : $Id: Locale.pm,v 1.15 2009/10/24 20:01:01 jv Exp $
# Author : Johan Vromans
# Created On : Fri Sep 16 20:27:25 2005
# Last Modified By: Johan Vromans
# Last Modified On: Sat Oct 24 22:00:58 2009
# Update Count : 117
# Status : Unknown, Use with caution!
package EB::Locale;
use strict;
our $VERSION = sprintf "%d.%03d", q$Revision: 1.15 $ =~ /(\d+)/g;
use base qw(Exporter);
use constant COREPACKAGE => "ebcore";
our @EXPORT_OK = qw(LOCALISER _T __x __n __nx __xn);
our @EXPORT = @EXPORT_OK;
# This module supports three different gettext implementations.
use POSIX qw(setlocale LC_MESSAGES);
my $gotone = 0;
unless ( $gotone ) {
eval {
require Locale::gettext;
# Use outer settings.
setlocale(LC_MESSAGES, $ENV{EB_LANG}||"");
our $core_localiser;
unless ( $core_localiser ) {
$core_localiser = Locale::gettext->domain(COREPACKAGE);
# Since EB is use-ing Locale, we cannot use the EB exported libfile yet.
$core_localiser->dir(EB::libfile("locale"));
}
eval 'sub _T($) {
$core_localiser->get($_[0]);
}';
eval 'sub LOCALISER() { "Locale::gettext" }';
$gotone++;
}
}
unless ( $gotone ) {
eval 'sub _T($) { $_[0] };';
eval 'sub LOCALISER() { "" }';
}
# Second alternative: Locale-gettext 1.05 (on CPAN).
# Simple and light-weight.
# It only provides the straight-forward translation, so we need
# to add the utility routines __x __n __xn __nx.
=begin later
use Locale::gettext 1.05;
use POSIX; # Needed for setlocale()
# Use outer settings.
setlocale(LC_MESSAGES, $ENV{EB_LANG}||"");
our $core_localiser;
unless ( $core_localiser ) {
$core_localiser = Locale::gettext->domain(COREPACKAGE);
$core_localiser->dir( libfile("locale") );
}
sub _T($) {
$core_localiser->get($_[0]);
}
sub LOCALISER() { "Locale::gettext" }
=cut
# Variable expansion. See GNU gettext for details.
sub __expand($%) {
my ($t, %args) = @_;
my $re = join('|', map { quotemeta($_) } keys(%args));
$t =~ s/\{($re)\}/defined($args{$1}) ? $args{$1} : "{$1}"/ge;
$t;
}
# Translation w/ variables.
sub __x($@) {
my ($t, %vars) = @_;
__expand(_T($t), %vars);
}
# Translation w/ singular/plural handling.
sub __n($$$) {
my ($sing, $plur, $n) = @_;
_T($n == 1 ? $sing : $plur);
}
# Translation w/ singular/plural handling and variables.
sub __nx($$$@) {
my ($sing, $plur, $n, %vars) = @_;
__expand(__n($sing, $plur, $n), %vars);
}
# Make __xn a synonym for __nx.
*__xn = \&__nx;
=begin alternative
# Third alternative: libintl-perl (GNU gettext) (on CPAN).
#
# This implementation provides a smart hash binding as well as object
# references.
# It also provides the utility routines __x __n __xn __nx and more.
use Locale::TextDomain( COREPACKAGE, libfile("locale") );
sub _T($) { $__->{$_[0]} }
sub LOCALISER() { "Locale::TextDomain" }
=cut
# Perl magic.
# *_=\&_T;
# More Perl magic.
1;
|