Smarty "capitalize" modifier ... always uses the letters "L"? ... and "P"?

Pretty simple: I use Smarty and the |capitalize modifier. It works fine, but when I pass the word l in it, it erases it, even if it is not at the beginning of the word.

Why?

EDIT : The same thing happens with p .

Test:

 {"abcdefghijklmnopqrstuvwxyz"|capitalize} {"aaal aala alaa laaa"|capitalize} {"aaap aapa apaa paaa"|capitalize} 

Conclusion:

 AbcdefghijkLmnoPqrstuvwxyz AaaL AaLa ALaa Laaa AaaP AaPa APaa Paaa 
+6
source share
2 answers

You can also use the PHP ucfirst function

 {"aaal aala alaa laaa"|@ucfirst} 

This will lead to

Aaal aala alaa laaa

+5
source

Smarty primarily relies on ucfirst() , which is affected by the current locale set in PHP. I could not find information on how this affects the capitalization functions (ucfirst, strtolower, strtoupper, etc.), but you can try setting your language to en_US.UTF-8 (which works on my server) and see how does this affect the result

view locale:

 var_dump(setlocale(LC_CTYPE, null)); 

change locale:

 setlocale(LC_CTYPE, "en_US.UTF-8"); 

Update

Some studies lead to several archives in which the user modifier is written either to select the local one for the modifier, or for a user-defined function to set the locale from the template file.

Source 1 Source 2

I could not reproduce this. Could this be the font you are using (some kind of tail l )? Do you have code examples?

With Smarty v2

 {assign value="let go" var="go"} {$go|capitalize} <br/> {assign value="allow me" var="me"} {$me|capitalize} 

Outputs

 Let Go <br/> Allow me 

Strike>

+2
source

Source: https://habr.com/ru/post/891158/


All Articles