I have an array of strings:
$items = array ('Silver', 'Black', 'Orange');
I would like to use WordPress _() function to make strings translation-ready, so I constructed the following and it works:
$items = array( __( 'Silver', 'my-textdomain' ), __( 'Black', 'my-textdomain' ), __( 'Orange', 'my-textdomain' ));
How can I avoid repeating text domain or even better, use my first array to create second array?
This seems to work:
$items = array ('Silver', 'Black', 'Orange');
foreach ($items as &$item) {
$item = __( $item, 'my-textdomain' );
}
unset($item);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.