Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there, sorry for the delay getting back, this was a bit of a head scratcher. In WP, plugins are loaded before themes so it wasn’t as easy as I thought.

    If you add this code to the bottom of functions.php in your theme the language should be changed to spanish:

    function cscf_change_language( $locale, $domain ) {
        if ( $domain == 'cleanandsimple') {
            return 'es_ES';
        }
        else {
            return $locale;
        }
    }
    add_filter( 'plugin_locale','cscf_change_language',10,2);
    if (class_exists('CSCF')) {
        $cscf = new CSCF;
        $cscf->RegisterTextDomain();
    }

    Basically at this point the language file has already been loaded, so we have to load it again, changing the language via a filter.

    The settings screen for the plugin will also be in Spanish, but there is no avoiding this unfortunately.

    Thread Starter fatbones

    (@fatbones)

    Worked perfectly!
    Thank you so much, Meg.

    Thread Starter fatbones

    (@fatbones)

    Oops, I’ve noticed that the settings screen appears duplicated.
    Watch in on: https://es.tinypic.com/r/23ljsk4/8

    Regards.

    Hi There,

    Try this code instead:

    function cscf_change_language( $locale, $domain ) {
        if ( $domain == 'cleanandsimple') {
            return 'es_ES';
        }
        else {
            return $locale;
        }
    }
    add_filter( 'plugin_locale','cscf_change_language',10,2);
    if (class_exists('CSCF')) {
        load_plugin_textdomain('cleanandsimple', false, 'clean-and-simple-contact-form-by-meg-nicholas/languages');
    }
    Thread Starter fatbones

    (@fatbones)

    Now it’s Ok.
    Thank you Meg.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change language without redefining 'WPLANG'’ is closed to new replies.