WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 2 down vote accepted

You cannot translate text you don’t know. The translator must know the text before it was submitted – impossible.

The only solution is: add all language strings manually for each sub site.

share|improve this answer
Okay. So just to clarify, there is no possible way to allow them to insert text on an admin plugin page and have that text display properly on their WooCommerce checkout page. However, whatever translation files they have should be able to translate it if I use text and do something like 'label' => __('This is a checkbox', 'plugin-domain'), correct? I'm new to translating, so pardon me if my questions seem silly. – Jeremiah Prummer Feb 3 '13 at 15:16
Yes, strings hard coded in a theme or plugin are translatable, unknown string are not. – toscho Feb 3 '13 at 15:18
Awesome, thanks so much for your help! One more thing. I've never used WPML before, but it's my understanding that as long as I properly use the WordPress translation functions it will automatically translate in WPML. Do you know if that is the case, or do I need to do something special to make this work? – Jeremiah Prummer Feb 3 '13 at 15:20
If you use always the same text domain it should work. I’m not familiar with WPML, I use Glotpress or Codestyling Localization usually. – toscho Feb 3 '13 at 15:22
Great, well thanks for your help. – Jeremiah Prummer Feb 3 '13 at 15:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.