WordPress.org

Ready to get started?Download WordPress

Forums

Facebook
[resolved] How to use fb_locale filter? (3 posts)

  1. wube
    Member
    Posted 1 year ago #

    I'd like to load FB scripts with correct locale (language is set by user, i'm using WPML plugin).

    First of all i changed og:lang meta tag:

    function myfunc_ogp_filter( $meta_tags ) {
    	$meta_tags[ 'http://ogp.me/ns#locale' ] = ICL_LANGUAGE_CODE.'_'.strtoupper(ICL_LANGUAGE_CODE);
    	return $meta_tags;
    }
    add_filter( 'fb_meta_tags', 'myfunc_ogp_filter' );

    And it works fine, but I don't know how to change locale using fb_locale filter. I tried:

    function myfunc_set_locale() {
    	return ICL_LANGUAGE_CODE.'_'.strtoupper(ICL_LANGUAGE_CODE);
    }
    add_filter('fb_locale', 'myfunc_set_locale');

    But it doesn't work.

    http://wordpress.org/extend/plugins/facebook/

  2. Niall Kennedy
    Member
    Plugin Author

    Posted 1 year ago #

    Facebook supports specific locales. See Internationalization on the Facebook Developers site for more information.

    If you are trying to represent a Spanish speaker in Mexico you would need to use es_LA for example (Spanish Latin America); es_MX does not match a Facebook locale and would not load the Facebook JavaScript SDK.

  3. wube
    Member
    Posted 1 year ago #

    Thanks, but is the example of myfunc_set_locale() function OK? It seems no to work at all. No matter what this function returns
    facebook: http://connect.facebook.net/es_ES/all.js script is always loaded with "es_ES" language code.

    So the question is not how to pass correct language codes, but how to use fb_locale filter to set locale.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic