RSS

trunk : 5536

lpsolit%gmail.com
2008-03-28 14:15:42
Revision ID: cvs-1:lpsolitgmail.com-20080328191542-ta7kfct45hsig7zl
Bug 425288: checksetup.pl displays messages using the first language available, alphabetically, rather than falling back to english if the desired language is not found - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wurblzap a=mkanat

collapse all collapse all

added added

removed removed

29
use Bugzilla::Constants;
29
use Bugzilla::Constants;
30
 
30
 
31
use File::Basename;
31
use File::Basename;
32
use POSIX ();
32
use POSIX qw(setlocale LC_CTYPE);
33
use Safe;
33
use Safe;
34
 
34
 
35
use base qw(Exporter);
35
use base qw(Exporter);
40
    install_string
40
    install_string
41
    template_include_path
41
    template_include_path
42
    vers_cmp
42
    vers_cmp
 
 
43
    get_console_locale
43
);
44
);
44
 
45
 
45
sub bin_loc {
46
sub bin_loc {
165
        }
166
        }
166
    }
167
    }
167
 
168
 
168
    # If we didn't want *any* of the languages we support, just use all
 
 
169
    # of the languages we said we support, in the order they were specified.
 
 
170
    # This is only done when you ask for a certain set of languages, because
 
 
171
    # otherwise @supported just came off the disk in alphabetical order,
 
 
172
    # and it could give you de (German) when you speak English.
 
 
173
    # (If @supported came off the disk, we fall back on English if no language
 
 
174
    # is available--that happens below.)
 
 
175
    if (!@usedlanguages && $params->{use_languages}) {
 
 
176
        @usedlanguages = @supported;
 
 
177
    }
 
 
178
    
 
 
179
    # We always include English at the bottom if it's not there, even if
169
    # We always include English at the bottom if it's not there, even if
180
    # somebody removed it from use_languages.
170
    # somebody removed it from use_languages.
181
    if (!grep($_ eq 'en', @usedlanguages)) {
171
    if (!grep($_ eq 'en', @usedlanguages)) {
304
    return map($_->{'language'}, (sort sortQvalue @qlanguages));
294
    return map($_->{'language'}, (sort sortQvalue @qlanguages));
305
}
295
}
306
 
296
 
 
 
297
sub get_console_locale {
 
 
298
    my $locale = setlocale(LC_CTYPE);
 
 
299
    # Some distros set e.g. LC_CTYPE = fr_CH.UTF-8. We clean it up.
 
 
300
    if ($locale =~ /^([^\.]+)/) {
 
 
301
        $locale = $1;
 
 
302
    }
 
 
303
    $locale =~ s/_/-/;
 
 
304
    # It's pretty sure that there is no language pack of the form fr-CH
 
 
305
    # installed, so we also include fr as a wanted language.
 
 
306
    if ($locale =~ /^(\S+)\-/) {
 
 
307
        $locale .= ",$1";
 
 
308
    }
 
 
309
    return $locale;
 
 
310
}
 
 
311
 
307
 
312
 
308
# This is like request_cache, but it's used only by installation code
313
# This is like request_cache, but it's used only by installation code
309
# for setup.cgi and things like that.
314
# for setup.cgi and things like that.
366
Returns a hash containing information about what version of Bugzilla we're
371
Returns a hash containing information about what version of Bugzilla we're
367
running, what perl version we're using, and what OS we're running on.
372
running, what perl version we're using, and what OS we're running on.
368
 
373
 
 
 
374
=item C<get_console_locale>
 
 
375
 
 
 
376
Returns the language to use based on the LC_CTYPE value returned by the OS.
 
 
377
If LC_CTYPE is of the form fr-CH, then fr is appended to the list.
 
 
378
 
369
=item C<indicate_progress>
379
=item C<indicate_progress>
370
 
380
 
371
=over
381
=over
47
use File::Basename;
47
use File::Basename;
48
use Getopt::Long qw(:config bundling);
48
use Getopt::Long qw(:config bundling);
49
use Pod::Usage;
49
use Pod::Usage;
50
use POSIX qw(setlocale LC_CTYPE);
 
 
51
use Safe;
50
use Safe;
52
 
51
 
53
BEGIN { chdir dirname($0); }
52
BEGIN { chdir dirname($0); }
54
use lib qw(. lib);
53
use lib qw(. lib);
55
use Bugzilla::Constants;
54
use Bugzilla::Constants;
56
use Bugzilla::Install::Requirements;
55
use Bugzilla::Install::Requirements;
57
use Bugzilla::Install::Util qw(install_string get_version_and_os);
56
use Bugzilla::Install::Util qw(install_string get_version_and_os get_console_locale);
58
 
57
 
59
######################################################################
58
######################################################################
60
# Live Code
59
# Live Code
62
 
61
 
63
# When we're running at the command line, we need to pick the right
62
# When we're running at the command line, we need to pick the right
64
# language before ever displaying any string.
63
# language before ever displaying any string.
65
$ENV{'HTTP_ACCEPT_LANGUAGE'} ||= setlocale(LC_CTYPE);
64
$ENV{'HTTP_ACCEPT_LANGUAGE'} ||= get_console_locale();
66
 
65
 
67
my %switch;
66
my %switch;
68
GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t',
67
GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t',

Loggerhead runs on Bazaar branches