Prev | Current Page 352 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"


The extra parameters are inserted into the translated string at the defined points. We
define these points using type specifiers, this is the same as when using the PHP
sprintf() function. This list describes the different type specifiers:
Argument Type Representation
%F Floating point Floating point
%f Floating point Floating point (locale aware)
%c Integer ASCII character (does not support UTF-8 multi-byte characters)
%b Integer Binary Number
%d Integer Decimal
%u Integer Decimal (Unsigned)
%x Integer Hexadecimal
%X Integer Hexadecimal
%o Integer Octal
%e Scientific Expression Decimal
%s String String
This example demonstrates how we use the JText::sprintf() method:
$value = JText::sprintf('SAVED_ITEMS', 3);
Chapter 9
[ 265 ]
If the translation for SAVED_ITEMS were Saved %d items, the returned value would
be Saved 3 items.
Alternatively, we can use the JText::printf() method. This method is comparable
to the PHP function printf(). This method returns the length of the resultant string
and outputs the translation.


Pages:
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
Rowy noclegi męskie skarpetki rowerowe wycieczki do Skandynawii pity mapa Niemiec