line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Locale.pm -- EB Locale setup (core version) |
4
|
|
|
|
|
|
|
# Author : Johan Vromans |
5
|
|
|
|
|
|
|
# Created On : Fri Sep 16 20:27:25 2005 |
6
|
|
|
|
|
|
|
# Last Modified By: Johan Vromans |
7
|
|
|
|
|
|
|
# Last Modified On: Tue Aug 14 12:28:39 2012 |
8
|
|
|
|
|
|
|
# Update Count : 165 |
9
|
|
|
|
|
|
|
# Status : Unknown, Use with caution! |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package EB::Locale; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# IMPORTANT: |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# This module is used (require-d) by module EB only. |
16
|
|
|
|
|
|
|
# No other modules should try to play localisation tricks. |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# Note: Only _T must be defined. The rest is defined in EB::Utils. |
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
6
|
|
22
|
use strict; |
|
6
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
168
|
|
21
|
|
|
|
|
|
|
|
22
|
6
|
|
|
6
|
|
17
|
use constant COREPACKAGE => "ebcore"; |
|
6
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
345
|
|
23
|
|
|
|
|
|
|
|
24
|
6
|
|
|
6
|
|
75
|
use base qw(Exporter); |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
554
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our @EXPORT_OK = qw(_T); |
27
|
|
|
|
|
|
|
our @EXPORT = @EXPORT_OK; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# This module supports three different gettext implementations. |
30
|
|
|
|
|
|
|
|
31
|
6
|
|
|
6
|
|
925
|
use POSIX qw(setlocale); |
|
6
|
|
|
|
|
8571
|
|
|
6
|
|
|
|
|
31
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $core_localiser; |
34
|
|
|
|
|
|
|
our $LOCALISER; # for outside checking |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub LC_MESSAGES { |
37
|
12
|
50
|
|
12
|
0
|
15
|
eval { POSIX::LC_MESSAGES() } || 5; |
|
12
|
|
|
|
|
953
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub __init__ { |
41
|
6
|
50
|
|
6
|
|
13
|
return if $core_localiser; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Since EB is use-ing Locale, we cannot use the EB exported libfile yet. |
44
|
6
|
|
|
|
|
17
|
my $dir = EB::libfile("locale"); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Use outer settings. |
47
|
6
|
|
|
|
|
10
|
setlocale(LC_MESSAGES); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Try Locale::gettext |
50
|
6
|
50
|
|
|
|
62
|
eval { |
51
|
6
|
|
|
|
|
1200
|
require Locale::gettext; |
52
|
0
|
|
|
|
|
0
|
$core_localiser = Locale::gettext->domain(COREPACKAGE); |
53
|
0
|
|
|
|
|
0
|
$core_localiser->dir($dir); |
54
|
0
|
|
|
|
|
0
|
eval 'sub _T { $core_localiser->get($_[0]) }'; |
55
|
0
|
|
|
|
|
0
|
$LOCALISER = "Locale::gettext"; |
56
|
|
|
|
|
|
|
} and return; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Try Locale::Messages (part of libintl-perl). |
59
|
6
|
50
|
|
|
|
12
|
eval { |
60
|
6
|
|
|
|
|
951
|
require Locale::Messages; |
61
|
0
|
|
|
|
|
0
|
Locale::Messages::bindtextdomain( COREPACKAGE, $dir ); |
62
|
0
|
|
|
|
|
0
|
Locale::Messages::textdomain(COREPACKAGE); |
63
|
0
|
|
|
|
|
0
|
eval 'sub _T { package Locale::Messages; turn_utf_8_on(gettext($_[0])) }'; |
64
|
0
|
|
|
|
|
0
|
$LOCALISER = "Locale::Messages"; |
65
|
|
|
|
|
|
|
} and return; |
66
|
6
|
50
|
|
|
|
20
|
return if $core_localiser; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Try Locale::gettext_xs (part of libintl-perl). |
69
|
6
|
50
|
|
|
|
7
|
eval { |
70
|
6
|
|
|
|
|
1052
|
require Locale::gettext_xs; |
71
|
0
|
|
|
|
|
0
|
Locale::gettext_xs::bindtextdomain( COREPACKAGE, $dir ); |
72
|
0
|
|
|
|
|
0
|
Locale::gettext_xs::textdomain(COREPACKAGE); |
73
|
0
|
|
|
|
|
0
|
eval 'sub _T { Locale::gettext_xs::gettext($_[0]) }'; |
74
|
0
|
|
|
|
|
0
|
$LOCALISER = "Locale::gettext_xs"; |
75
|
|
|
|
|
|
|
} and return; |
76
|
6
|
50
|
|
|
|
21
|
return if $core_localiser; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Try Locale::gettext_pp (part of libintl-perl). |
79
|
6
|
50
|
|
|
|
8
|
eval { |
80
|
6
|
|
|
|
|
2220
|
require Locale::gettext_pp; |
81
|
0
|
|
|
|
|
0
|
Locale::gettext_pp::bindtextdomain( COREPACKAGE, $dir ); |
82
|
0
|
|
|
|
|
0
|
Locale::gettext_pp::textdomain(COREPACKAGE); |
83
|
0
|
|
|
|
|
0
|
eval 'sub _T { Locale::gettext_pp::gettext($_[0]) }'; |
84
|
0
|
|
|
|
|
0
|
$LOCALISER = "Locale::gettext_pp"; |
85
|
|
|
|
|
|
|
} and return; |
86
|
6
|
50
|
|
|
|
18
|
return if $core_localiser; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Fallback to none. |
89
|
6
|
50
|
|
|
|
15
|
unless ( $core_localiser ) { |
90
|
6
|
|
|
|
|
7
|
$core_localiser = ""; |
91
|
6
|
|
|
61
|
|
193
|
eval 'sub _T { $_[0] };'; |
|
61
|
|
|
|
|
202
|
|
92
|
6
|
|
|
|
|
15
|
$LOCALISER = ""; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub get_language { |
97
|
0
|
|
|
0
|
0
|
0
|
$ENV{LANG}; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub set_language { |
101
|
|
|
|
|
|
|
# Set/change language. |
102
|
6
|
|
|
6
|
0
|
10
|
setlocale( LC_MESSAGES, $ENV{LANG} = $_[1] ); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__init__(); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |