Translating the “Everything” filter menu in Quicksand jquery file

You should be able to pass the language across using wp_localize_script().

So you’re obviously enqueuing your own custom javascript file, lets say that file is called createlist.js.

I assume you’re doing it like so:

wp_enqueue_script( 'createlist', plugins_url( 'createlist.js', __DIR__ ), array( 'jquery' ), '1.0', true );

(You’ll need to adjust the path for the JS file based on where you have it, if this is in a theme or a plugin, do you have sub-directories, etc.

Immediately after that you’ll want to also do something like:

if( !empty( $post ) ) :
    //research how to run a conditional check for PolyLang being active
    wp_localize_script( 'createlist', 'createlist_object',
        array(
            //pll_get_post_language( $post_id, $field ); - this is what you need
            'currentLang'       => pll_get_post_language( $post->ID, 'slug' ) //assuming that's how it works
        )
    );
endif;

In the above section, I’d also recommend you look into PolyLang and see if the documentation recommends a class you can look for to see if it exists before you try to retrieve a language, you should only execute functions that are plugin dependent IF that plugin is active. So you’ll need to look into that too. Don’t write code that assumes that something will ALWAYS be the case.

Now in your javascript file you’ll want to retrieve what we just localized like so:

// First we get the current language we localized when the script loaded
var currentLang         = createlist_object.currentLang;
console.log( currentLang ); //so you can test and see which is which
// Now we check that variable against potential options
if( currentLang == 'en_GB' ) {
    createList( 'View All', items );
} else if( currentLang == 'fr_FR' ) {
    createList( 'Tous', items );
} else {
    // always include a fallback incase nothing is found or nothing matches
    createList( 'View All', items );
}

You’ll have to run some tests though because I don’t know which field value gives you what when using pll_get_post_language( $post_id, $field )

‘$field’ => (optional) either ‘name’ or ‘locale’ or ‘slug’, defaults to ‘slug’

No clue which of those will spit out en_GB and fr_FR so test thoroughly. (This is why I added the console.log( currentLang ); to the JS, comment that out or delete it once you figure out which field you need.

I think that covers it, best of luck.

Oh, here’s the PolyLang link:
https://polylang.pro/doc/function-reference/

casinojojobetpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casinocanlı bahis casino siteleriOnwin Güncel Girişholiganbetholiganbet girişholiganbet güncel giriş