Skip Navigation

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.

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Nicolas V. 1 year, 10 months ago.

Assisted by: Nicolas V..

Author Posts
June 9, 2023 at 9:00 am #13797987

leonieB

In the functions.php for the above site we have the following code:

function awcfe_profiel_dropdown_field( $fields ) {

$profiel_args = wp_parse_args( array(
'type' => 'select',
'options' => array(
'' => __( 'Selecteer profiel' ),
'FCA deelnemer' => 'FCA deelnemer',
'FCA auditor' => 'FCA auditor',
'FCA consulent' => 'FCA consulent',
'auditor' => 'Auditor',
'consulent' => 'Consulent',
'andere' => 'Andere',
),
'input_class' => array(
'country_select',
)
), $fields['billing']['billing_profiel'] );

$fields['billing']['billing_profiel'] = $profiel_args;

return $fields;

}

add_filter( 'woocommerce_checkout_fields', 'awcfe_profiel_dropdown_field', 999999, 1 );

The text is not translated into English and French. What should I do to make it translatable?
Thanks in advance!

June 9, 2023 at 5:06 pm #13801431

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Welcome to the WPML support forum.

I think that you should add a domain name to your translation function. For example:

__( 'Selecteer profiel', 'domaine_name_here' )

References:
https://wpml.org/documentation/support/translating-the-theme-you-created/
https://developer.wordpress.org/reference/functions/__/

- After that you can rescan your theme in "WPML > Theme and plugins localization"
- Then go to "WPML > String Translation" to find those strings and translate them

June 13, 2023 at 3:03 pm #13818517

leonieB

This what i did:

function awcfe_profiel_dropdown_field( $fields ) {

$profiel_args = wp_parse_args( array(
'type' => 'select',
'options' => array(
'' => __( 'Selecteer profiel', 'ovocom-academy.com' ),
'FCA deelnemer' => 'FCA deelnemer',
'FCA auditor' => 'FCA auditor',
'FCA consulent' => 'FCA consulent',
'auditor' => 'Auditor',
'consulent' => 'Consulent',
'andere' => 'Andere',
),
'input_class' => array(
'country_select',
)
), $fields['billing']['billing_profiel'] );

$fields['billing']['billing_profiel'] = $profiel_args;

return $fields;

}

add_filter( 'woocommerce_checkout_fields', 'awcfe_profiel_dropdown_field', 999999, 1 );

The strings are not showing.

June 13, 2023 at 7:41 pm #13820009

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Here is a video where I followed exactly the steps I instructed in my previous answer and I can see the string now in "WPML > String translation".

hidden link

Let me know if it helps you or please give me more details on the issue because for me it seems to work correctly.

June 16, 2023 at 1:44 pm #13840195

leonieB

Hi there,

Thanks for the reply. That works for me too. But that's not the only thing that needs translation.
This is what is still not working:

'FCA deelnemer' => 'FCA deelnemer',
'FCA auditor' => 'FCA auditor',
'FCA consulent' => 'FCA consulent',
'auditor' => 'Auditor',
'consulent' => 'Consulent',
'andere' => 'Andere',

How do i translate that?
Thank you!

June 16, 2023 at 7:38 pm #13842587

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

I'm sorry if I didn't explain myself enough. You need to use the __() function for each text:

'FCA deelnemer' => __( 'FCA deelnemer', 'ovocom-academy.com' ),
'FCA auditor' => __( 'FCA auditor', 'ovocom-academy.com' ),
'FCA consulent' => 'FCA consulent', 'ovocom-academy.com' ),
'auditor' => __( 'Auditor', 'ovocom-academy.com' ),
'consulent' => __( 'Consulent', 'ovocom-academy.com' ),
'andere' => __( 'Andere', 'ovocom-academy.com' ),

1. Please always make a backup of your your functions.php before modifying it.
2. Remember to rescan the theme in "WPML > Theme and plugins localization"
3. Then texts will be available in "WPML > String Translation"

Have a great weekend,
Nico