From c56f5e3c03177edf52172c8a164f66c354d0e147 Mon Sep 17 00:00:00 2001 From: "wurblzap%gmail.com" <> Date: Wed, 22 Aug 2007 01:47:51 +0000 Subject: Bug 365378 – The 'languages' parameter is not necessary. Patch by Marc Schumann ; r=LpSolit; a=LpSolit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Bugzilla.pm') diff --git a/Bugzilla.pm b/Bugzilla.pm index e4947fbe1..47cf256ff 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -40,6 +40,7 @@ use Bugzilla::Util; use Bugzilla::Field; use File::Basename; +use File::Spec::Functions; use Safe; # This creates the request cache for non-mod_perl installations. @@ -308,6 +309,24 @@ sub dbh { return request_cache()->{dbh}; } +sub languages { + return request_cache()->{languages} if request_cache()->{languages}; + + my @files = glob(catdir(bz_locations->{'templatedir'}, '*')); + my @languages; + foreach my $dir_entry (@files) { + # It's a language directory only if it contains "default" or + # "custom". This auto-excludes CVS directories as well. + next unless (-d catdir($dir_entry, 'default') + || -d catdir($dir_entry, 'custom')); + $dir_entry = basename($dir_entry); + # Check for language tag format conforming to RFC 1766. + next unless $dir_entry =~ /^[a-zA-Z]{1,8}(-[a-zA-Z]{1,8})?$/; + push(@languages, $dir_entry); + } + return request_cache()->{languages} = \@languages; +} + sub error_mode { my $class = shift; my $newval = shift; @@ -627,6 +646,11 @@ used to automatically answer or skip prompts. The current database handle. See L. +=item C + +Currently installed languages. +Returns a reference to a list of RFC 1766 language tags of installed languages. + =item C Switch from using the main database to using the shadow database. -- cgit v1.2.3-24-g4f1b