Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Baden on "String localization for variables"

$
0
0

In the following example string_1 and string_2 are used as the select value of an option element, however the display text is translated.

$option_arr = array('string_1', 'string_1');
foreach($option_arr AS $opt){
	echo '<option value="'.$opt."'>'.__($opt, 'text_domain').'</option>';
}

This works so long as string_1 and string_2 are manually entered into the .pot file.

So that these strings may be discovered by i18n tools such as makepot.php, is there a better practice than simply declaring the strings manually like so:

//these are only so that makepot.php knows they exist
$string_1 = __('string_1', 'text_domain');
$string_2 = __('string_2', 'text_domain');

Viewing all articles
Browse latest Browse all 8245

Trending Articles