Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter miguelcortereal

    (@miguelcortereal)

    And here comes another enhacement for this plugin.

    Search functionality isn’t WPML compatible. This is an increasing requested feature that follows localization.

    To make it compatible we need to transform the URL submission search in this:

    eg: http://www.mydomain.com/en/?s=oursearch

    WPML plugin became a standard in multilanguage for WordPress, so use their API is wise, nevertheless Polylang is another multilanguage plugin which I use, growing faster in users, that has a WPML compatibility interface.
    This is just to justify the type of selection being made when it comes to multilanguage.

    To have my responsive menu search box working in a multilanguage environment using Polylang plugin and able to work with WPML as well, I hacked the plugin at /responsive-menu/app/library/responsive-menu/View.php and edited this function as follows:

    /**
         * Function to format and display the search bar in the main menu
         *
         * @param  array  $status
         * @return string
         * @added 2.0
         */
    
        static function searchBar() {
    
        if (function_exists('icl_get_home_url')) { ?>
            <form action="<?php echo icl_get_home_url(); ?>" id="responsiveSearch" method="get" role="search">
            <?php } else { ?>
            	<form action="<?php echo home_url(); ?>" id="responsiveSearch" method="get" role="search">
            <?php } ?>
                <input type="search" name="s" value="" results=5 autosave=responsive-menu placeholder="<?php echo __('Search', 'responsive-menu'); ?>" id="responsiveSearchInput">
                <input type="submit" style="display: none;" />
            </form>
       <?php
        }

    Note that it includes the correction to the search box placeholder translation and the replacement of get_site_url() by home_url()

    Thread Starter miguelcortereal

    (@miguelcortereal)

    Hopefuly this will be the last correction to this function.:)

    W3C validator returns 2 errors on it:

    Attribute results=5 and attribute autosave=responsive-menu for the <input> tag.

    Hi miguel,

    Thanks for the suggestions.

    I have now made the Search part translateable, included the WPML function support and removed the invalid markup so the W3C validator should return back with no errors in the 2.2 beta.

    If you can download and test it for me, then that would be great. You can find it on the following URL:

    https://downloads.wordpress.org/plugin/responsive-menu.2.2.zip

    Many thanks

    Peter

    Thread Starter miguelcortereal

    (@miguelcortereal)

    Hi Peter

    Let it be me thanking you for your nice job with this plugin instead.

    It is working as expected and after looking more deep into the code, looks like it’s fully WPML compliant.

    • You’re firing strings translation with plugins_loaded
    • You already have a wpml-config.xml file for the most important options.

    After this small improvement, you should announce at plugin’s features, Multilanguage support (WPML and Polylang).

    Thread Starter miguelcortereal

    (@miguelcortereal)

    Sorry, I’ve spoken too soon.

    The options from wpml-config.xml, which I’m reproducing here:

    <wpml-config>
        <admin-texts>
            <key name="RMOptions">
                <key name="RM" />
                <key name="RMClickTitle" />
                <key name="RMTitle" />
                <key name="RMImage" />
                <key name="RMClickImage" />
            </key>
        </admin-texts>
    </wpml-config>

    need to be present at wp_otions table, so that the multilanguage plugin can filter them and make them translatable. Looks like you’re using a different aproach and thus those options fields never get extended to receive different values for each language.
    Not sure, but it sounds to me they should be registered using:
    register_setting( $option_group, $option_name, $sanitize_callback );

    Hi miguel,

    Those options are available in the wp_options table.

    The wp_options table will include an option named “RMOptions” and then is an array that holds the keys “RM”, “RMClickTitle” etc.

    I have this setup on my development sites and they work correctly with Polylang/WPML.

    Many thanks

    Peter

    Thread Starter miguelcortereal

    (@miguelcortereal)

    That’s great.

    Then I guess your plugin has full WPML support now.

    My configuration isn’t returning available those options for translation, but it might be related with something else than your plugin which I’ll have to pay atention.

    Hi miguel,

    Thanks for your kind suggestions and words for the plugin.

    Please let me know if you experience any other issues and I will look to help out.

    Many thanks

    Peter

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Make search box placeholder translatable’ is closed to new replies.