Ce sujet est résolu. Voici une description du problème et de la solution.
Problem: You are managing multilingual options on your website with English as the default language and French as the secondary. When updating an option with the same value as the default language, the French option in the database becomes empty. This occurs due to the behavior in WPML's class-wpml-multilingual-options.php. Solution: This behavior is intentional for optimization in WPML. If the translated option value is identical to the original language's value, WPML deletes the translated option to avoid duplication in the database. This means that if the values are the same, WPML will not store them separately and will fall back to the original value. If you need to force the translation of admin strings or save options in different languages, consider using the following hooks:
If this solution does not apply to your case, or if it seems outdated, we recommend opening a new support ticket. Also, check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. For further assistance, please visit our support forum.
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 du WPML répond sur le forum 6 jours par semaine, 22 heures par jour.
Contexte de la question:
I am trying to manage multilingual options on my website, which has English (EN) as the default language and French (FR) as the secondary language. I created an option using update_option('test', 'test value') and made it multilingual with do_action('wpml_multilingual_options', 'test'). When I update the option with a different value for FR, it works as expected. However, if I update the option with the same value as EN, the FR option becomes empty due to line 126 in class-wpml-multilingual-options.php.
Symptômes:
When updating the option with the same value as the original language, the FR option in the database becomes empty: option_name = test_fr, option_value = ''.
Questions:
Is the behavior of the FR option becoming empty when it has the same value as the original language expected?
Am I missing something in handling options with the same value as the original language?
I'm already using #2 as you can see from the code. Only it doesn't behave the way Ilyes describe, instead of avoiding the duplication in the database it does create another empty line, which will return an empty value on query of course.
I made another WPML_Multilingual_Options class which handles things the way they should. I'm confused about why I'm the only one having this problem, definitely not related to other plugins (I tested on a fresh install without plugins other than WPML), but it works now.