Search code examples
phpwordpresswoocommerceqtranslate

qTranslate + WooCommerce-qTML + WooCommerce Aggiungere CF e P.IVA not translate custom fields in checkout page


I have a problem with my project. I'm using a Wordpress theme NOT native for WooCommerce. I'm implemented anyway WooCommerce, and it works great. Now, i have a problem. WooCommerce doesn't contain italian custom fields "C.F." and "P.IVA". So i've found a plugin that provides to create and configure these custom fields. The plugin is: http://netstarsolution.net/aggiungere-cf-e-pi-wc/.

The problem is that when i active qTranslate and WooCommerce-qTML (for WooCommerce), the custom fields inserted by "WooCommerce Aggiungere CF e P.IVA" not are translated. Only custom fields inserted with "WooCommerce Aggiungere CF e P.IVA" plugin doesn't works.

This is the part that's not translating:

// Billing First Name. 
$fields['billing']['billing_first_name'] = array( 
    'label' => __( 'First Name', 'wcbcf' ), 
    'placeholder' => _x( 'First Name', 'placeholder', 'wcbcf' ), 
    'required' => true, 
    'class' => array( 'form-row-first' ),
);

Solution

  • Ok I resolved it. Post here the solution for someone that has my same problem.

    Well, the solution is basically a hack to the plugin itself (NOT the qTranslate plugin, just the other ones ONLY). What you do is find within the plugin the load_plugin_textdomain function call.

    Code:

        load_plugin_textdomain('your_plugin_identifier', false, dirname( plugin_basename(__FILE__) ) . '/languages');
    
    add_action('init', 'init_textdomain');
    function init_textdomain() {
       load_plugin_textdomain(''your_plugin_identifier', false, dirname( plugin_basename(__FILE__) ) . '/languages');
    }
    

    Thanks to this post: http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=1800