note 107761 added to function.gettext

From: Date: Fri, 02 Mar 2012 11:28:01 +0000
Subject: note 107761 added to function.gettext
Groups: php.notes 
Request: Send a blank email to php-notes+get-186465@lists.php.net to get a copy of this message
If you want to have variables in your text to be translated the usual way would be with string formatting like so: <?php printf(gettext("Hello %s!"), $world); ?> This works because the string substitution is made after gettext performs. The human translator needs to be aware of what %s represents, when there are many variables in a line it can get confusing. To have more meaningful variable names you can use code like the below: <?php print str_replace(array('#WORLD#'), array($world), gettext('Hello #WORLD#!')); ?> Now the human translator will see #WORLD# which is more meaningful than "%s". He must be careful not to translate the variable name but leave it intact. It is also easier to change the order in which variables are used instead of printf's arcane "%2$s". ---- Server IP: 109.169.40.147 Probable Submitter: 87.194.177.60 ---- Manual Page -- http://www.php.net/manual/en/function.gettext.php Edit -- https://master.php.net/note/edit/107761 Del: integrated -- https://master.php.net/note/delete/107761/integrated Del: useless -- https://master.php.net/note/delete/107761/useless Del: bad code -- https://master.php.net/note/delete/107761/bad+code Del: spam -- https://master.php.net/note/delete/107761/spam Del: non-english -- https://master.php.net/note/delete/107761/non-english Del: in docs -- https://master.php.net/note/delete/107761/in+docs Del: other reasons-- https://master.php.net/note/delete/107761 Reject -- https://master.php.net/note/reject/107761 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#186465) next »