| 1 | package Serge::Engine::Plugin::parse_key_space_value; | ||||||||||
| 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 | sub name { | ||||||||||
| 7 | 0 | ▶ | return 'Plain key<_space_>value string parser'; | ||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 8 | } | ||||||||||
| 9 | |||||||||||
| 10 | sub parse { | ||||||||||
| 11 | 0 | ▶ | my ($self, $textref, $callbackref, $lang) = @_; | ||||||||
|
Subroutine
parse: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | die 'callbackref not specified' unless $callbackref; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | |||||||||||
| 15 | 0 | my $translated_text = $$textref; | |||||||||
| 16 | |||||||||||
| 17 | # Finding translatable strings in file | ||||||||||
| 18 | |||||||||||
| 19 | # Format is: | ||||||||||
| 20 | # key value | ||||||||||
| 21 | # key\tvalue | ||||||||||
| 22 | # (leading and trailing whitespaces are preserved but are not extracted as a string or as a hint) | ||||||||||
| 23 | |||||||||||
| 24 | # $1 $2 $3 $4 $5 | ||||||||||
| 25 | 0 | $translated_text =~ s|^(\s*)(\S+)(\s+)(.+?)(\s*)$|$1.$2.$3.$self->parse_callback($callbackref, $4, undef, $2, undef, $lang).$5|mgie; | |||||||||
| 26 | |||||||||||
| 27 | 0 | return $translated_text; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | sub parse_callback { | ||||||||||
| 31 | 0 | ▶ | my ($self, $callbackref, $string, $context, $hint, $flagsref, $lang) = @_; | ||||||||
|
Subroutine
parse_callback: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 32 | |||||||||||
| 33 | 0 | my $translated_string = &$callbackref($string, $context, $hint, $flagsref, $lang); | |||||||||
| 34 | |||||||||||
| 35 | 0 | $translated_string =~ s/\n/\\n/sg; | |||||||||
| 36 | |||||||||||
| 37 | 0 | return $translated_string; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 1 | 1; | |||||||||