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

Last updated by chongweiC 1 year, 9 months ago.

Assisted by: Ahmed Mohammed.

Author Posts
May 13, 2023 at 5:12 am #13639655

chongweiC

Hi,

I read https://wpml.org/documentation/support/translating-the-theme-you-created/ and I understand that the plugin will use different PO & MO files for different languages. However, I just wonder which language will it choose? To my understand, when it invokes load_theme_textdomain, it will detect the locale of the current post/page, and then use that locale to find the corresponding PO/MO file. Is that correct?

May 15, 2023 at 9:10 am #13646103

Ahmed Mohammed
Supporter

Timezone: Africa/Cairo (GMT+02:00)

Hi there,

Thank you for contacting WPML support!

.. it will detect the locale of the current post/page, and then use that locale to find the corresponding PO/MO file. Is that correct?

I'd like to mention that the document you shared pertains to the translation of themes and plugin text for developers. It's actually an extended version of this document: https://developer.wordpress.org/themes/functionality/internationalization/.

To answer your question, yes, using load_theme_textdomain is the correct way to load the appropriate .po and .mo files for the theme strings based on the language selected.

However, it's worth noting that translating posts and pages works a bit differently. When you translate a post or page, it creates a new entry in the database. When you view that post or page in a different language, WPML retrieves the translated version from the database, rather than from the .mo/.po files.

Hope that helps 🙂