| 1 | package Serge::Engine::Plugin::parse_resx; | ||||||||||
| 2 | 1 | ▶ | use parent Serge::Engine::Plugin::Base::Parser; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Serge::Util qw(xml_escape_strref xml_unescape_strref); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | sub name { | ||||||||||
| 9 | 0 | ▶ | return '.Net .resx parser plugin'; | ||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 10 | } | ||||||||||
| 11 | |||||||||||
| 12 | sub parse { | ||||||||||
| 13 | 0 | ▶ | my ($self, $textref, $callbackref, $lang) = @_; | ||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | die 'callbackref not specified' unless $callbackref; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | |||||||||||
| 17 | # Finding translatable strings in file | ||||||||||
| 18 | |||||||||||
| 19 | # Format is: | ||||||||||
| 20 | # <data name="...hint..." ...> | ||||||||||
| 21 | # <value>...string...</value> | ||||||||||
| 22 | # </data> | ||||||||||
| 23 | |||||||||||
| 24 | 0 | my $translated_text = $$textref; | |||||||||
| 25 | |||||||||||
| 26 | 0 | $translated_text =~ s|(<data.*?name=")(.*?)(".*?>.*?<value[^\/]*?>)(.*?)(</value>)|$1.$2.$3.$self->parse_callback($callbackref, $4, undef, $2, undef, $lang).$5|sge; | |||||||||
| 27 | |||||||||||
| 28 | 0 | return $translated_text; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | sub parse_callback { | ||||||||||
| 32 | 0 | ▶ | my ($self, $callbackref, $string, $context, $hint, $flagsref, $lang) = @_; | ||||||||
|
Subroutine
parse_callback: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 33 | |||||||||||
| 34 | 0 | xml_unescape_strref(\$string); | |||||||||
| 35 | |||||||||||
| 36 | 0 | my $translated_string = &$callbackref($string, $context, $hint, $flagsref, $lang); | |||||||||
| 37 | |||||||||||
| 38 | 0 | xml_escape_strref(\$translated_string); | |||||||||
| 39 | |||||||||||
| 40 | 0 | return $translated_string; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 1 | 1; | |||||||||