Edit report at https://bugs.php.net/bug.php?id=65321&edit=1
ID: 65321 Updated by: yohg...@php.net Reported by: nico dot weinreich at gmail dot com Summary: Extend sprintf function by type specifier for uppercase and lowercase -Status: Open +Status: Wont fix Type: Feature/Change Request -Package: Unknown/Other Function +Package: Strings related Operating System: All PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Current PHP does not have default multibyte string module. So it's not feasible. Previous Comments: ------------------------------------------------------------------------ [2013-07-25 00:24:40] anon at anon dot anon Easily done in user land. function foo($s) { $args = func_get_args(); return preg_replace_callback('/%(.)/', function($matches) use(&$args) { switch ($matches[1]) { case '%': return '%'; case 's': return next($args); case 't': return mb_convert_case(next($args), MB_CASE_LOWER); case 'T': return mb_convert_case(next($args), MB_CASE_UPPER); } }, $s); } echo foo('Alla %t på %s', 'Uppslagsord', 'K'); -> Alla uppslagsord på K ------------------------------------------------------------------------ [2013-07-24 08:10:45] nico dot weinreich at gmail dot com Description: ------------ I'm using sprintf() to realize multi language setup of my projects in a simple way, e.g.: $l['Stichworte'] = 'Uppslagsord'; $l['Alle %s mit %s'] = 'Alla %s på %s'; Base language is german, target language is swedish. On runtime I'm doing something like: echo sprintf(Lang::get("Alle %s mit %s"), Lang::get("Stichworte"), 'K'); So I get for german 'Alle Stichworte mit K' and for swedish 'Alla Uppslagsord på K'. The problem is, in this context the word 'Uppslagsord' has to be in lowercase for swedish. So it would be great, if there are two more type specifiers for sprintf() to allow text transformation, e.g.: %s - the argument is treated as and presented as a string %t - the argument is treated as and presented as a lowercase string %T - the argument is treated as and presented as a uppercase string ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65321&edit=1