Skip Navigation

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

Problem:
The client needs to retrieve the default language code of a string in PHP, regardless of the site's default language, specifically for a user description that has a different default language in the WPML String Translation tab.
Solution:
We recommend using WPML's filters and action hooks for proper multilingual support within themes or plugins. Here are some resources that may help:

If necessary, the default language of a string can be changed in the String Translation section. For more details, visit How to change the source language of strings.
Please note that custom coding support is beyond the scope of our support forum. If you require additional custom work, consider contacting WPML Contractors at WPML Contractors.

If this solution doesn't look relevant, please open a new support ticket.

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 1 reply, has 2 voices.

Last updated by Waqas Bin Hasan 1 year, 7 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
September 13, 2023 at 11:14 am #14389685

Gauvain

Hello,

For a plugin I need to get the default language code of a string, regardless of the site default language, in my case a user description (for exemple the site default language is french, but the string translation default language for a user description is in english in the "string translation" tab of WPML). Is it possible to achieve that in PhP ?

I have the string's registered domain and the string's registered name

September 14, 2023 at 11:36 am #14396487

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

WPML offers filters and action hooks that can be used in your WordPress theme or plugin to provide correct multilingual support. Browse following resources for more information:

- https://wpml.org/documentation/support/wpml-coding-api/
- https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/
- https://wpml.org/documentation/support/wpml-coding-api/shortcodes/
- https://wpml.org/faq/how-to-get-current-language-with-wpml/
- https://wpml.org/documentation/support/wpml-tables/
- https://wpml.org/documentation/related-projects/woocommerce-multilingual/wcml-hooks-reference/
- https://wpml.org/documentation/support/

Other than that you can change string's default language from String Translation also, see https://wpml.org/documentation/getting-started-guide/string-translation/how-to-change-the-source-language-of-strings/ for details, if that matters.

Please note that support for custom coding is out of scope of this forum.

If you need additional custom work, we recommend you contact WPML Contractors at https://wpml.org/contractors/.

Regards.