Quite simply: I'm using Smarty and the |capitalize
modifier. It works fine, but when I pass any word with l
in it, it capitalizes it, even if it's not at the beginning of the word.
What why?
EDIT: Same happens with p
.
Test:
{"abcdefghijklmnopqrstuvwxyz"|capitalize}
{"aaal aala alaa laaa"|capitalize}
{"aaap aapa apaa paaa"|capitalize}
Output:
AbcdefghijkLmnoPqrstuvwxyz
AaaL AaLa ALaa Laaa
AaaP AaPa APaa Paaa
You could also use PHP's ucfirst function
{"aaal aala alaa laaa"|@ucfirst}
This will result in
Aaal aala alaa laaa
Smarty primarily relies on ucfirst()
which is affected by the current locale set in PHP. I have been unable to find information on exactly how this affects the capitalization functions (ucfirst, strtolower, strtoupper, etc), but you can try setting your locale to en_US.UTF-8
(what works on my server) and see how that affects the output.
view locale:
var_dump(setlocale(LC_CTYPE, null));
change locale:
setlocale(LC_CTYPE, "en_US.UTF-8");
Some research leads to a few archives where a customer modifier is written to either pick the local for the modifier or a custom function to set the locale from the template file.
Source 1 Source 2
I haven't been able to reproduce this. Could it be the font you are using (some tail the 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With