This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Bobby 4 months ago.

Assigned support staff: Bobby.

Author Posts
June 13, 2019 at 6:36 pm

stephanieK-9

I am trying to: translate extra field, added to functions.php in child theme with plugin "salon booking system"

Link to a page where the issue can be seen: hidden link
(end of the steps, field "notice"

I expected to see: German version, dont know how exactly

Instead, I got: English

I needed to add this to functions.php to enable extra fields at checkout.

add_filter('sln.checkout.additional_fields',function(){
return array(
'custom_field_a'=> array(
"label" => 'Custom field A',
"type" => 'text',
"width" => 'full',
"default" => 'Your default value',
"customer_profile" => true
),
'custom_field_b'=> array(
"label" => 'Custom field B',
"type" => 'textarea',
"width" => 'half',
"default" => 'Your default value'
),
'custom_field_c'=> array(
"label" => 'Custom field C',
"type" => 'select',
"options" => array('option_a','option_b', 'option_c'),
"width" => 'half',
"default" => 'option_a'

),
'custom_field_d'=> array(
"label" => 'Custom field D',
"type" => 'checkbox'
),

);
});

with that code I was able to translate my newsletter - any idea how to adapt the language based to the browsers selection like here?

so "notice" will be "notiz" in German version. I think I have to merge this code to the above for the right language.

thank you for helping me!

function cp_callback_function( $display, $style_id ) {
     
        if( $style_id == 'xxxxxx' && ICL_LANGUAGE_CODE == 'en') return true;
	    if( $style_id == 'xxxxxx' && ICL_LANGUAGE_CODE == 'de') return false;
        if( $style_id == 'xxxxxx' && ICL_LANGUAGE_CODE == 'de') return true;
        if( $style_id == 'xxxxxx' && ICL_LANGUAGE_CODE == 'en') return false;

    return $display;

}
June 13, 2019 at 10:34 pm #4017215

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi There,

if you need to translate a string i would recommend wrapping your string in a gettext call so our WPML String Translation add-on plugin can register it and allow you to add a translation

=> https://wpml.org/faq/language-setup/

let me know your results please

The topic ‘[Closed] can't translate extra field’ is closed to new replies.