pradosoft / prado

Prado - Component Framework for PHP
Other
186 stars 71 forks source link

Include additional text when localizing a validator's text #450

Open ctrlaltca opened 11 years ago

ctrlaltca commented 11 years ago

From ra...@bhatia.at on March 14, 2013 19:11:40

I would like to add additional text/HTML code when localizing a validator's text. For example, i want to add a

example 1 (working):

example 2 (not working):

This seems to be rooted in TTemplate::parseAttribute(), line 896:

else if(pregmatch('/\s(<%~.?%>|<%\$.?%>|<%[.?]%>|<%\/.?%>)\s_/msS',$value,$matches) && $matches[0]===$value)

There, it correctly matches the localization tag but checks if the $matches[0] equals $value, which isn't true for the second example because:

$matches[0] is "<%[Please enter your email address!]%>" but $value is "<%[Please enter your email address!]%>
".

Is there a possibility to fix this?

Thanks, Raoul

Original issue: http://code.google.com/p/prado3/issues/detail?id=449

ctrlaltca commented 11 years ago

From ctrlal...@gmail.com on March 16, 2013 08:16:55

Adding the check for a prefix/suffix is something that can be done. Unfortunately in the current implementation the parsing code is shared between different kind of tags (asset, localization, parameter, expression tags), and this makes any change to the code potentially dangerous: it will need a lot of testing. In the meanwhile, a quick workaround is to use <%= Prado::localize('Please enter your email address!')."
" %> instead.

Labels: -Type-Defect -Priority-Medium -Milestone-3.2.2 Type-Enhancement Priority-NiceToHave Milestone-3.3a

ctrlaltca commented 11 years ago

From ra...@bhatia.at on March 16, 2013 09:04:09

i agree. maybe more tests in this regard would be needed... or a seperate elseif branch ;)