Support » Plugin: Fast Secure Contact Form » URL parameter change language not working in WordPress 4.0

  • Resolved Nethub

    (@nethub)


    Hello,

    We were using Fast Secure Contact Form with qtranslate in WordPress 3.6 previously, it was working fine to display correct language in the contact form (by detecting URL). (e.g. “Comments or questions are welcome” becomes “歡迎批評指教” for Chinese)

    Recently we installed WordPress 4.0 and Fast Secure Contact Form 4.0.30, it seems the URL detecting is not working any more which suppose to be working (http://www.fastsecurecontactform.com/translate-php , no matter /tw/ or ?lang=tw).

    I found that si-contact-form is using function load_plugin_textdomain to load the lanugage in class-fscf-util.php, hence I added below code to display what locale and mofile it got, now I supprise that it is “en_US” for si-contact-form while other plugins load correctly.

    wp-includes/l10n.php

    function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) {
            $locale = get_locale();
            /**
             * Filter a plugin's locale.
             *
             * @since 3.0.0
             *
             * @param string $locale The plugin's current locale.
             * @param string $domain Text domain. Unique identifier for retrieving translated strings.
             */
            $locale = apply_filters( 'plugin_locale', $locale, $domain );
    
            if ( false !== $plugin_rel_path ) {
                    $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
            } else if ( false !== $deprecated ) {
                    _deprecated_argument( __FUNCTION__, '2.7' );
                    $path = ABSPATH . trim( $deprecated, '/' );
            } else {
                    $path = WP_PLUGIN_DIR;
            }
    
            // Load the textdomain according to the plugin first
            $mofile = $domain . '-' . $locale . '.mo';
    ob_start();
    echo "<BR><BR>-----------------------------------------<BR>\r\n";
    echo $locale . " : " . $mofile . "<BR>\r\n";
                    return $loaded;
    
            // Otherwise, load from the languages directory
            $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
            return load_textdomain( $domain, $mofile );
    }

    Here is the demo site to show the problem:
    http://t.nethub.com.hk/tmp/webeasy/tw/contact-us/

    https://wordpress.org/plugins/si-contact-form/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi nethub what version of qtranslate do you have installed?

    Thread Starter Nethub

    (@nethub)

    Sorry that I forgot to mention in new WordPress 4.0 I installed “mqtranslate” instead of “qtranslate”, which is a fork of qtranslate, it is because qtranslate has no update for long long time and mqtranslate currently uses the qtranslate core with updated patch to support new WordPress.

    The mqtranslate version I installed is : Version 2.8

    https://wordpress.org/plugins/mqtranslate/

    Hi thank you for reporting back.

    There is also qTranslate Plus which is also a fork of qTranslate. However they are still in early stages and I know the developers of both plugins are doing a great job. I know many bugs will pop up from time to time.

    In regards to the conflict it has with Fast Secure Contact Form, this is something that @mike Challis would have to look at.

    Regards

    Thread Starter Nethub

    (@nethub)

    Finally we found the core cause.

    It is because si-contact-form load the priority as 1 (default:10), so that it is loaded before the translation plugin. I don’t know why si-contact-form needs to load in the very first place, I think it is not necessary. Hope future release would correct it.

    Temporary solution:
    file: wp-content/plugins/si-contact-form/includes/class-fscf-util.php
    add_action('plugins_loaded', 'FSCF_Util::fscf_init_languages', 1);

    Change to

    add_action('plugins_loaded', 'FSCF_Util::fscf_init_languages');

    @nethub I am happy to hear that you have finally solved your issue.

    If you don’t require any more help can you mark this support thread as resolved.

    I will let @mike Challis know about your fix above.

    Kind regards

    Thread Starter Nethub

    (@nethub)

    Oh yes, marked as resolved, thanks.

    OK I will fix that in the next version

    Mike

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘URL parameter change language not working in WordPress 4.0’ is closed to new replies.