WordPress.org

Ready to get started?Download WordPress

Forums

Dave's WordPress Live Search
How to enable translation files? (6 posts)

  1. eriksan1
    Member
    Posted 2 years ago #

    There are dwls.pot, dwls-sv_SE.po and dwls-sv_SE.mo files in the language folder, but the pot and po files appear empty when opening in poedit version 1.4.6.

    A half hour later, I managed to open the spanish translation file in the poedit catalog manager. I overwrote the swedish po file and the translatino works, except the string "view more results" still does not change! Tried clearing browser and plugin cache.

    http://wordpress.org/extend/plugins/daves-wordpress-live-search/

  2. Torsten Landsiedel
    Member
    Posted 2 years ago #

    I have exactly the same problem (DWLS 2.8).

    If I try to use the dwls.pot I get an empty PoEdit-File.

    If I take another language and change it to my language it will work, but "View more result" is still showing in english, although it is translated and prepared for translation [ __('View more results', dwls') ].

    I think it is the only frontend-string, maybe this is the problem, because all backend-strings are working fine ...

    Kind regards
    Torsten

  3. Robert Windisch
    Member
    Posted 1 year ago #

    Here is the solution for the problem. You need to change the following Function in the file DavesWordPressLiveSearch.php

    Current Version 2.8 Code

    public static function advanced_search_init() {
            if (self::isSearchablePage()) {
                wp_enqueue_script('jquery');
    
                wp_enqueue_script('daves-wordpress-live-search', plugin_dir_url(__FILE__).'js/daves-wordpress-live-search.js', 'jquery');
                self::inlineSettings();
            }
    
            load_plugin_textdomain('dwls', false, dirname( plugin_basename( __FILE__ )) . '/languages/');
        }

    Change into this Function:

    public static function advanced_search_init() {
            load_plugin_textdomain( 'dwls', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
            if ( self::isSearchablePage() ) {
                wp_enqueue_script( 'daves-wordpress-live-search', plugin_dir_url( __FILE__ ) . 'js/daves-wordpress-live-search.js', array( 'jquery' ) );
                self::inlineSettings();
            }
        }

    Hints to the solution:

    • The function "load_plugin_textdomain" need to be loaded before self::inlineSettings
    • The request of jQuery can be made in "wp_enqueue_script" with the parameter "jQuery" as an array in dependencies, currently jQuery is loaded before because the parameter is a string and should be an array
  4. Torsten Landsiedel
    Member
    Posted 1 year ago #

    This is so awesome!

    Thank you very much again, Robert! This was a great WP Camp Germany. I love this community ...

    Best Regards
    Torsten

  5. Dave Ross
    Member
    Plugin Author

    Posted 1 year ago #

    Great catch, Robert! I've always just passed a string for the dependency and never had a problem. I wonder if I just got lucky, or there's some weird combination of PHP & WordPress settings that causes this to be a problem. Regardless, the Codex says that needs to be an array, and an array it shall be!

  6. Second
    Member
    Posted 1 year ago #

    Gosh, I'm still having "View more results" not translate... wonder if I'm doing something wrong?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic