Translations are no longer loading from the theme folder

[ad_1]

Take a look at this ticket on core trac: https://core.trac.projectdmc.org/ticket/62337

Hello ,
In WordPress 6.7, changes in translation handling emphasize loading translations from the centralized wp-content/languages/themes/ directory. While not a bug, it’s a shift in behavior intended to standardize where WordPress looks for translations, moving towards using a dedicated languages directory rather than loading from within theme folders.Best Practices for Theme Translations in WP 6.7 and Beyond

  1. Primary Translation Location: Place translations in wp-content/languages/themes/ with the filename convention {theme-slug}-{locale}.mo (e.g., your-theme-fr_FR.mo). WordPress will prioritize this directory, allowing you to load translations without custom code.
  2. Using load_theme_textdomain in Your Theme:
    • You can still call load_theme_textdomain, but specify the wp-content/languages/themes/ directory if you want to explicitly control where WordPress loads translations from:
load_theme_textdomain( 'your-theme', WP_LANG_DIR . '/themes' );

3. Fallback with load_textdomain (for Development or Custom Scenarios):

  • If you prefer to keep translations within your theme folder for development, you can continue using load_textdomain as a fallback. Just be aware this may not align with WordPress’s intended file structure for production environments.
  • Example:
load_textdomain( 'your-theme', get_template_directory() . '/languages/your-theme-fr_FR.mo' );

Thank you both for your answers!

All the best
Christian

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer