WordPress.org

Ready to get started?Download WordPress

Forums

Facebook AWD All in one
[resolved] Like button is not localized (10 posts)

  1. Misamee
    Member
    Posted 3 years ago #

    This is quite odd.

    Usually the like button and all other Facebook buttons, widgets and boxes are automatically localized.

    With this plugin I always get an English localization.
    Looking to the source code, I don't see anything that forces the English localization, and still, I can't get it in the right language (Italian, in my case).

    If I try with the Facebook wizard (from here) I get it in Italian.

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

  2. AHWEBDEV
    Member
    Plugin Author

    Posted 3 years ago #

    Yep i will add this feature in the next release...

    For the moment, if you want to localized the plugin (only facebook part) you can.

    You have to go in your plugin folder and open folder "facebook-awd"
    Open the file AWD_facebook.php

    Search for the line n 1021:
    "document.location.protocol + '//connect.facebook.net/en_US/all.js';"

    You can see that the localisation is en_US
    If you want french, you can replace us_US by fr_FR

    You can replace it by any lang that exist on facebook.
    I will add some hook and some custom in admin, to set the lang.

  3. Misamee
    Member
    Posted 3 years ago #

    Thank you: this does the job.

    If I may suggest, in the future release I would add, in addition to some hook and custom in admin, an option to automatically detect the languages, based on user's browser localization.

    Something like that (found in comments about http_negotiate_language, here):

    <?php
    /*
      determine which language out of an available set the user prefers most
    
      $available_languages        array with language-tag-strings (must be lowercase) that are available
      $http_accept_language    a HTTP_ACCEPT_LANGUAGE string (read from $_SERVER['HTTP_ACCEPT_LANGUAGE'] if left out)
    */
    function prefered_language ($available_languages,$http_accept_language="auto") {
        // if $http_accept_language was left out, read it from the HTTP-Header
        if ($http_accept_language == "auto") $http_accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
    
        // standard  for HTTP_ACCEPT_LANGUAGE is defined under
        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
        // pattern to find is therefore something like this:
        //    1#( language-range [ ";" "q" "=" qvalue ] )
        // where:
        //    language-range  = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
        //    qvalue         = ( "0" [ "." 0*3DIGIT ] )
        //            | ( "1" [ "." 0*3("0") ] )
        preg_match_all("/(:alpha:{1,8})(-([[:alpha:]|-]{1,8}))?" .
                       "(\s*;\s*q\s*=\s*(1\.0{0,3}|0\.\d{0,3}))?\s*(,|$)/i",
                       $http_accept_language, $hits, PREG_SET_ORDER);
    
        // default language (in case of no hits) is the first in the array
        $bestlang = $available_languages[0];
        $bestqval = 0;
    
        foreach ($hits as $arr) {
            // read data from the array of this hit
            $langprefix = strtolower ($arr[1]);
            if (!empty($arr[3])) {
                $langrange = strtolower ($arr[3]);
                $language = $langprefix . "-" . $langrange;
            }
            else $language = $langprefix;
            $qvalue = 1.0;
            if (!empty($arr[5])) $qvalue = floatval($arr[5]);
    
            // find q-maximal language
            if (in_array($language,$available_languages) && ($qvalue > $bestqval)) {
                $bestlang = $language;
                $bestqval = $qvalue;
            }
            // if no direct hit, try the prefix only but decrease q-value by 10% (as http_negotiate_language does)
            else if (in_array($languageprefix,$available_languages) && (($qvalue*0.9) > $bestqval)) {
                $bestlang = $languageprefix;
                $bestqval = $qvalue*0.9;
            }
        }
        return $bestlang;
    }
    ?>
  4. AHWEBDEV
    Member
    Plugin Author

    Posted 3 years ago #

    Thank you very much,

    I really prefer let the user set the languages in administration.

    You can now define locale in plugin settings.
    if empty Default is equal to WPLANG, else if WPLANG is empty,
    plugin will use en_US.

    Because, if a user choose to use facebook in spannish in facebook account, the sdk facebook will do the rest.

    You use to go on facebook from a lot of differents browsers and never with the same language.

    Try the new version 0.9.6!

  5. Misamee
    Member
    Posted 3 years ago #

    I see your point. Mine was only an advice for an additional option (nothing forced by the plugin itself).

    My WPLANG is already set to it_IT, but since facebook doesn't seem to automatically get user's preferred language (unless now it does with the new plugin version I still have to try it), I was thinking my suggestion as a workaround.

    By the way, thank you for the update!

  6. AHWEBDEV
    Member
    Plugin Author

    Posted 3 years ago #

    Yep, I unserstood the need...

    I will see that later, if someone are asked for same feature.

    You can Set your languages with hook if you want.

    Just add filter like that

    function mycustom_function($options){
       $options['locale'] = 'it_IT';//or prefered_languages();
    }
    //filter hook for all options
    add_filters('AWD_options','mycustom_function',1,1);

    (set priority to 10 but maybe should change it.)
    This filter is call at the end of init.php

  7. Misamee
    Member
    Posted 3 years ago #

    Actually, the filter it's enough: thanks!

  8. henkdijkstraal
    Member
    Posted 2 years ago #

    I just installed this plugin, but the like-button is still showing in English, though I have nl_NL in 'locale' under 'settings' (version 0.9.8). My WordPress install is also in nl_NL.

  9. henkdijkstraal
    Member
    Posted 2 years ago #

    When I edit a post, I get these custom fields on my post-page. How can I get rid of them?

    awd_fcbk_option_ogtags_title: etc.
    wd_fcbk_option_ogtags_type:
    ...

    so I see this information on the website... strange?

  10. AHWEBDEV
    Member
    Plugin Author

    Posted 2 years ago #

    For your first question,

    You should use xfbml instead of iframe to let facebook detect your lang.

    For the second quesiton:

    I have to modify the plugin to use the custom field with an underscore above the key.
    _awd_fcbk_option_ogtags_title instead of awd_fcbk_option_ogtags_title.
    To hide them in the post editor.

    This will be done in 0.9.9

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic