diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-03-03 15:28:46 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-03-04 10:22:20 +0000 |
commit | 3221050312712d79d1e430b7863d93207d3ed973 (patch) | |
tree | c0f7d6b14fddfff14f6511720ae4e13b260afdae /perllib/FixMyStreet/Template.pm | |
parent | 1af670b53a35a439e74a2b16bb031cf74a8e1c63 (diff) |
Use existing loc() so translations find strings.
The gettext-extract script looks for loc() in templates, it did not find
the loc_js() calls.
Diffstat (limited to 'perllib/FixMyStreet/Template.pm')
-rw-r--r-- | perllib/FixMyStreet/Template.pm | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/Template.pm b/perllib/FixMyStreet/Template.pm index fbd51dcb7..6317f7552 100644 --- a/perllib/FixMyStreet/Template.pm +++ b/perllib/FixMyStreet/Template.pm @@ -62,23 +62,13 @@ sub process { [% loc('Some text to localize', 'Optional comment for translator') %] Passes the text to the localisation engine for translations. +Pass in "JS" as the optional comment to escape single quotes (for use in JavaScript). =cut sub loc : Fn { my $s = _(@_); - return FixMyStreet::Template::SafeString->new($s); -} - -=head2 loc_js - -Same as loc() but escapes single quotes (for use in JavaScript). - -=cut - -sub loc_js : Fn { - my $s = _(@_); - $s =~ s/'/\\'/g; + $s =~ s/'/\\'/g if $_[1] && $_[1] eq 'JS'; return FixMyStreet::Template::SafeString->new($s); } |