Il s'agit du forum d'assistance technique de WPML, le plug-in multilingue pour WordPress.

Il est accessible à tous, toutefois seuls les clients de WPML peuvent y publier leurs messages. L'équipe de WPML répond aux messages du forum 6 jours sur 7, 22 heures sur 24.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum French. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user was not able to translate labels for a custom form using the following code

"civility",
"radio",
array(
"label"=>"Civility",
"profile"=>true,
"options"=>array(
"mr"=>"Mr",
"ms"=>"Ms"
),
)

Solution:
The above code does not implement the localization api of WordPress. We should use the following code instead

"civility",
"radio",
array(
"label"=>__("Civility", "your-domain"),
"profile"=>true,
"options"=>array(
"mr"=>__("Mr", "your-domain"),
"ms"=>__("Ms", "your-domain")
),
)

Then the strings will be available for translation in WPML->String Translation under the used domain "your-domain".
Relevant Documentation:
https://codex.wordpress.org/I18n_for_WordPress_Developers

This topic contains 2 réponses, has 2 participants.

Last updated by houdebert il y a 2 mois et 1 semaine.

Assigned support staff: Jamal.

Auteur Messages
août 9, 2019 à 9:20 #4368943

houdebert

Hello, i have create a custom form and i dont see how to prepare it for the translation
label and dropdown option. here you can see a field

Could you tell me how to do that i check documentation but i did not find
thank you

"civility",
"radio",
array(
"label"=>"Civility",
"profile"=>true,
"options"=>array(
"mr"=>"Mr",
"ms"=>"Ms"
),
)

août 9, 2019 à 10:31 #4369493

Jamal
Supporter

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

Timezone: Africa/Casablanca (GMT+01:00)

Hello,

Thank you for contacting WPML Support. I will be glad to help with this.

You may want to replace your code by introducing localization function __() with the following:

"civility",
"radio",
array(
"label"=>__("Civility", "your-domain"),
"profile"=>true,
"options"=>array(
"mr"=>__("Mr", "your-domain"),
"ms"=>__("Ms", "your-domain")
),
)

You may read more about localization functions in this WordPress article
https://codex.wordpress.org/I18n_for_WordPress_Developers

Then the strings "Civility", "Mr", and "Ms" will be available for translation in WPML->String Translation under the domain "your-domain".

I hope this helps. If it does not, please elaborate more with details and in a way like:
1. I go to xxx
2. I do xxx
3. I expect to have xxx
4. Instead, I get xxx

Please also, paste your WPML Debug information in the Debug information field?
- http://wpml.org/faq/provide-debug-information-faster-support/

PS: Feel free to use French as you have posted this ticket into the French support forum.

Best regards,
Jamal
WPML Support

août 9, 2019 à 3:38 #4371649

houdebert

My issue is resolved now. Thank you!