March 2011
Beginner to intermediate
300 pages
7h 23m
English
Some of you may have realized that there are some messages that need to include additional bits of data, such as a number of records returned:
$msg = "3 fields deleted";
In the scenario above, "3" is a variable. In this case, you can wrap your messages using the sprintf() function, just like we did in Chapter 3:
$cnt_fields_deleted = 3; $translated_msg = sprintf( __( '%s fields deleted', 'your-textdomain'), $cnt_fields_deleted );
This preserves the integrity of the message for translation purposes, and it allows you to better inform the user about what is going on.
Read now
Unlock full access