This thread is resolved. Here is a description of the problem and solution.
Problem:
You are trying to translate a string from Hebrew to English using the
wpml_translate_single_string
hook in WPML, but it fails to translate into the website's default language (English), while it successfully translates into Russian.
Solution:
The
wpml_translate_single_string
hook does not translate into the default language because WPML assumes the string in the default language is the original value and does not store translations for it. To retrieve a translation based on the current language, use the default language string as the source and pass the current language as the target:
$current_lang = apply_filters('wpml_current_language', null);<br />$translated = apply_filters('wpml_translate_single_string', 'Subject en', 'admin_texts_woocommerce_new_order_settings', '[woocommerce_new_order_settings]subject', $current_lang);<br />error_log($translated);
This method uses the default language string ('Subject en') as the source, and WPML looks up the appropriate translation for the current language. For further understanding, you might find these guides helpful:
- https://wpml.org/wpml-hook/wpml_translate_single_string/
- https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/#wpml_translate_single_string
If this solution does not apply to your case, or if it seems outdated, we recommend opening a new support ticket. We also highly suggest checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. For further assistance, please visit our support forum: WPML Support Forum.
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 0 voices.
Last updated by 1 month, 2 weeks ago.
Assisted by: Carlos Rojas.