[Typo3-dev] locallang-entry with variable in between
Martin Kutschker
martin.kutschker at no5pam.blackbox.net
Tue Jun 21 09:15:43 CEST 2005
"Robert Lemke" <robert at typo3.org> schrieb im Newsbeitrag
news:mailman.1.1119305640.906.typo3-dev at lists.netfielders.de...
> Bernhard Kraft wrote:
>
>> If you do:
>>
>> $result = sprintf('Variable 1: %s .... Variable 2: %s', $var1, $var2);
>>
>> Then the contents of the occurencies of %s will be replaced by the vars
>> after the string in the order they appear ...
>>
>> you can achieve the same with
>> $result = str_replace('%s', $var1, $origStr);
>>
>> Normally you should choose sprintf if you replace %s and str_replace for
>> all others. (sprintf is some kinf of C relict for people who don't know
>> about str_replace)
>
> That's the way we do it currently and I don't have a better idea, but be
> aware that there might be problems if the order must be different in other
> languages:
>
> Some languages might write "of 8: 4" instead of "4 of 8".
sprintf supports argument swapping. The default language (ie English)
defines the correct argumet order for the sprintf statement, and the
localized formar strings define the semantic order (see
http://www.php.net/manual/en/function.sprintf.php).
Masi
More information about the TYPO3-dev
mailing list