Support » Plugin: Facebook » How to use fb_locale filter?

  • Resolved wube


    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[ '' ] = 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Niall Kennedy


    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.



    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: 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to use fb_locale filter?’ is closed to new replies.