diff options
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r-- | Bugzilla.pm | 24 |
1 files changed, 24 insertions, 0 deletions
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<DBI>. +=item C<languages> + +Currently installed languages. +Returns a reference to a list of RFC 1766 language tags of installed languages. + =item C<switch_to_shadow_db> Switch from using the main database to using the shadow database. |