WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Change language without redefining 'WPLANG'

[Resolved] Change language without redefining 'WPLANG'

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author megnicholas

    @megnicholas

    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.

    Worked perfectly!
    Thank you so much, Meg.

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

    Regards.

    Plugin Author megnicholas

    @megnicholas

    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');
    }

    Now it’s Ok.
    Thank you Meg.

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