summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Util.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-09-14 15:57:29 +0200
committermkanat%bugzilla.org <>2006-09-14 15:57:29 +0200
commit761ae5de8e84ffd70489260364db5789ec135b55 (patch)
treea488a2e5b3605444791ba414dde70ee6292e1cab /Bugzilla/Util.pm
parent47ee48a70f9abe53bc5e934f6e83c997b350dc6b (diff)
downloadbugzilla-761ae5de8e84ffd70489260364db5789ec135b55.tar.gz
bugzilla-761ae5de8e84ffd70489260364db5789ec135b55.tar.xz
Bug 352608: Make checksetup more localizable
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=myk
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r--Bugzilla/Util.pm45
1 files changed, 44 insertions, 1 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 8821a6c66..c051a987f 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -43,7 +43,8 @@ use base qw(Exporter);
format_time format_time_decimal validate_date
file_mod_time is_7bit_clean
bz_crypt generate_random_password
- validate_email_syntax clean_text);
+ validate_email_syntax clean_text
+ get_text);
use Bugzilla::Constants;
@@ -397,6 +398,20 @@ sub clean_text {
return trim($dtext);
}
+sub get_text {
+ my ($name, $vars) = @_;
+ my $template = Bugzilla->template;
+ $vars ||= {};
+ $vars->{'message'} = $name;
+ my $message;
+ $template->process('global/message.txt.tmpl', $vars, \$message)
+ || ThrowTemplateError($template->error());
+ # Remove the indenting that exists in messages.html.tmpl.
+ $message =~ s/^ //gm;
+ return $message;
+}
+
+
sub get_netaddr {
my $ipaddr = shift;
@@ -683,6 +698,34 @@ ASCII 10 (LineFeed) and ASCII 13 (Carrage Return).
Returns the parameter "cleaned" by exchanging non-printable characters with spaces.
Specifically characters (ASCII 0 through 31) and (ASCII 127) will become ASCII 32 (Space).
+=item C<get_text>
+
+=over
+
+=item B<Description>
+
+This is a method of getting localized strings within Bugzilla code.
+Use this when you don't want to display a whole template, you just
+want a particular string.
+
+It uses the F<global/message.txt.tmpl> template to return a string.
+
+=item B<Params>
+
+=over
+
+=item C<$message> - The identifier for the message.
+
+=item C<$vars> - A hashref. Any variables you want to pass to the template.
+
+=back
+
+=item B<Returns>
+
+A string.
+
+=back
+
=back
=head2 Formatting Time