• Despite of this code:

    `define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
    define( 'WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);

    if ('de.' == substr( $_SERVER['HTTP_HOST'], 0, 3 )) {
    define ('WPLANG', 'de_DE');
    }
    if ('en.' == substr( $_SERVER['HTTP_HOST'], 0, 3 )) {
    define ('WPLANG', 'en_EN');
    }

    if ('fr.' == substr( $_SERVER['HTTP_HOST'], 0, 3 )) {
    define ('WPLANG', 'fr_FR');
    }
    if ('es.' == substr( $_SERVER['HTTP_HOST'], 0, 3 )) {
    define ('WPLANG', 'es_ES');

    Only the english and the german versions work, not the french one (spanish is for the future). If I set french as admin language I see the translations, but not just putting the subdomain fr.sacconicase.com. I cant see why my code cant understand the locale language for french

    I got some answers form the A.I. but from the theoretically point of view I shoulndt need any new code. The A.I:

    Model 09:30
    This debug result is extremely valuable and tells us exactly where the problem lies.
    Let’s analyze the output:
    Domain Host: fr.sacconicase.com (Correct)
    WPLANG Constant: fr_FR (Your wp-config.php is working and the constant is defined!)
    get_locale() current: it_IT (WRONG. WordPress is ignoring the WPLANG constant and using Italian)
    Why does this happen?
    The most likely cause on a modern WordPress site (version 4.0 or later) is that the language setting in the database (in the wp_options table, WPLANG option) is overriding the constant defined in wp-config.php.
    In simple terms: your database says the site language is Italian, and WordPress uses that, ignoring the config.
    The Ultimate Solution
    We need to tell WordPress to use the language defined in wp-config.php (or the domain), ignoring the one saved in the database.
    The right place to do this is at the beginning of functions.php, so that it is executed before WordPress loads the options from the database.
    Action: Remove the debug code and replace it with this block at the top of your functions.php (after the <?php tag):
    code
    PHP
    // ===================================================================================================================
    // FORCE LOCALE FROM CONFIG/DOMAIN (Ignore DB setting)
    // Fixes debugging issue where WPLANG was fr_FR but get_locale() remained it_IT
    // ========================================================================================

    add_filter( ‘locale’, ‘sacconicase_force_locale_from_config’, 1 );

    ..and so on with more code…

    thank you

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter sacconi

    (@sacconi)

    thank you. Just a curiosity, I noticed that chat gtp gives me code with much more unusefull white lines, how can automatically reduce the lenght of the code, mantaining just the logical separations?

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.