Change English language of icons social networks k2 –

comes with built-in functionality of social networks in the items or content articleshowever this functionality for the k2 and google+ networks is found only in the English language (versions 2.5.x). In this article we will see how to make modifications to the default template of virtuemart to change the default language of English that are displayed on these social networks; later we will extend the functionality to handle multiple languages ​​on a multilanguage site.

Hosting Mautic QuickStart -50% with support in Spanish
24 hours and free training

Send up to 1,000,000 emails/year. Mautic Support in Spanish 24 hours, 365 days

1- Activation of social networks in k2

By default, this functionality is activated to create a new k2 category, in the item display options section => Share on social networks, as shown in the attached image.

For a website configured in the Spanish language it will be displayed by default as follows, as shown in the image, only twitter translates into Spanish, facebook and google do not

2- Editing the k2 template files

We can do an override by working directly on the file /templates/TEMPLATE_ACTUAL/html/com_k2/item.php(in case you don’t have this file it would be necessary to copy it from k2), or we can work directly on the k2 template file /components/com_k2/templates/default/item.php in any case we locate the code of social networks from line 210 approximately.

-To Facebook

We locate the following beginning of code

js.src = “//connect.facebook.net/en_US/…

and we change it for the desired language, for example for Spanish

See also  The images of the credit cards that stripe exhibits in...

js.src = “//connect.facebook.net/es_ES/…

-for google+

We locate the following beginning of code

window.___gcfg = {lang: ‘en’}…

and we change it to the desired language, for example for Spanish:

window.___gcfg = {lang: ‘en’}…

3- Social networks for a multi-language site

In case our website is multilanguage then it will be necessary to make a modification at the PHP level

We insert the following before the social media code

$lang = JFactory::getLanguage();
$google_lang = explode(‘-‘, $lang->getTag());
$facebook_lang = str_replace(‘-‘,’_’,$lang->getTag());

?>

Then we replace in the lines indicated in point 2 by the corresponding variables, for example

-To Facebook

js.src = “//connect.facebook.net/

-for google+

window.___gcfg = {lang: ‘‘}…

4- Final result

After making these modifications, then we will have the social network icons translated in k2

In the following video each of the points explained above is explained in a practical way.

Help us improve our content by sharing your opinion

WordPress technical support at and regular speaker at Meetups and WordCamps in America.

Loading Facebook Comments ...
Loading Disqus Comments ...