Automatic language detection option (with solution)
-
I have a bilingual website so I need the language of the FB comments to change with the page rather than being set in the settings for all pages.
I’ve added this functionality by adding an ‘Automatic’ option to the language drop down in the admin settings, I’ve also set this as the default option. If the language is set to ‘Automatic’ the plugin uses
get_locale();
to determine the current language.I’ve made the following changes:
class-admin.php line 31
From
'language' => 'en_US'
to
'language' => ''
class-admin.php line 172
Added the line
<option value="" <?php selected( $options['language'], '' ); ?>>- Automatic -</option>
class-frontend.php line 38
From:
js.src = "//connect.facebook.net/<?php echo $options['language']; ?>/sdk.js#xfbml=1&appId=<?php echo $options['appID']; ?>&version=v2.3";
To:
js.src = "//connect.facebook.net/<?php echo ($options['language'])? $options['language'] : get_locale() ; ?>/sdk.js#xfbml=1&appId=<?php echo $options['appID']; ?>&version=v2.3";
I hope someone else finds this useful
- The topic ‘Automatic language detection option (with solution)’ is closed to new replies.