From everything I've read, you should only translate text strings via the WP translation functions like _e()
or __()
. However, I need a way to translate content submitted via a form. Is there some solution that will allow me to translate text outputted in a variable? Here's what I'm doing:
I'm working on a plugin for a company and they need the ability to set the description text for a checkbox via a form on the back end. The checkbox will be placed on a WooCommerce checkout page. They're using the WPML plugin, and want that text to be translatable. Here's what I naturally would want to do, but I know it's wrong:
woocommerce_form_field( 'my_checkbox', array(
'type' => 'checkbox',
'class' => array('input-checkbox'),
'label' => __( $sample_variable , 'woothemes'),
'required' => false,
),
Here's what I think I should do, but it doesn't seem to work:
woocommerce_form_field( 'my_checkbox', array(
'type' => 'checkbox',
'class' => array('input-checkbox'),
'label' => sprintf( __('%s', 'woothemes'), $mpo_check_box_desc ),
'required' => false,
),
Any help would be much appreciated, thank you!