Keyword

K2 on multilanguage sites

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 11 months ago - 11 years 11 months ago #113436 by Filip Nikitovic
K2 on multilanguage sites was created by Filip Nikitovic
Hi,
i have multilanguage site,in german and english.
I would like to make a blog using K2.

Im testing it at the moment but I cant manage to set it for two diferent laguages.

Can You please help?

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
11 years 11 months ago #113437 by Yiota
Replied by Yiota on topic Re: K2 on multilanguage sites
Do you have different content for each language or the same translated with Joomfish, for example?

Please Log in or Create an account to join the conversation.

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 11 months ago - 11 years 11 months ago #113438 by Filip Nikitovic
Replied by Filip Nikitovic on topic Re: K2 on multilanguage sites
Same content for each language but its not auto translated.

Im not using Joomfish, Im using built in Joomla language plug-in and I made pages for both languages separately.

I will be doing same with blog,I will create blog post in english and translate it my self to german for german blog.

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
11 years 11 months ago #113439 by Yiota
Replied by Yiota on topic Re: K2 on multilanguage sites
So you actually write one item and assign it to English and then create another item and assign it to German.
In the menu you can select the Language for each menu item which would appear in the frontend depending on the language selection.

Please Log in or Create an account to join the conversation.

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 11 months ago #113440 by Filip Nikitovic
Replied by Filip Nikitovic on topic Re: K2 on multilanguage sites

So you actually write one item and assign it to English and then create another item and assign it to German.


Yes thats right.

In the menu you can select the Language for each menu item which would appear in the frontend depending on the language selection.


Sorry,are you still talking about Joomla or You are now talking about K2 item?

Becouse I created K2 categorie and item, and selected german language. (image1 and image2)

Attachment not found



Attachment not found



And I created Joomla menu item,for menu item type I selected K2 categories and selected german language.(image3)

Attachment not found



When I open that page in front end text is still in english (image4)

Attachment not found

Attachments:

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago - 11 years 11 months ago #113441 by Lefteris
Replied by Lefteris on topic Re: K2 on multilanguage sites
I see that the German content is published in the correct category, German Blog.
Assuming that the item I see is indeed the correct one and the K2 elements are the ones that do not change I have to ask: Have you installed the K2 translation pack for German?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 11 months ago - 11 years 11 months ago #113442 by Filip Nikitovic
Replied by Filip Nikitovic on topic Re: K2 on multilanguage sites
Now I did and everything is in german,except facebook like button.
Is that normal?

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
11 years 11 months ago #113443 by Yiota
Replied by Yiota on topic Re: K2 on multilanguage sites
Even if you browse English pages you get german language on K2 elements?

Please Log in or Create an account to join the conversation.

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 11 months ago - 11 years 11 months ago #113444 by Filip Nikitovic
Replied by Filip Nikitovic on topic Re: K2 on multilanguage sites
Sorry if I confused You.
I mean everything is ok.
German pages are in german and english pages are in english.
Im asking about facebook like button on german page ,it writes "like" in english.
Is that normal?

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
11 years 11 months ago #113445 by Yiota
Replied by Yiota on topic Re: K2 on multilanguage sites
The default code for the like button is English.

There is a way you could change that depending on the language but it would require some modification to the item.php file in your override (templates/yourTemplate/html/com_k2/default/item.php).

Locate the facebook button and make an if statement to check the language. If it is English, leave the default else replace in the script block the '//connect.facebook.net/en_US/all.js'; with '//connect.facebook.net/de_DE/all.js';

Please Log in or Create an account to join the conversation.

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 11 months ago #113446 by Filip Nikitovic
Replied by Filip Nikitovic on topic Re: K2 on multilanguage sites
Thank You.

Just to check , if I change item.php as You told me then facebook "like" button will be in german on german pages and in english language on english pages.
Is that correct?

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
11 years 11 months ago #113447 by Yiota
Replied by Yiota on topic Re: K2 on multilanguage sites
Don't forget to make an if statement and check the language.
Try this:

$lang = JFactory::getLanguage();
$locale = $lang->getTag();

if ($locale=='de-DE'):
include the facebook button with the change I suggested for the script block;
else :
leave the default facebook button code.
endif;

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #113448 by Jo
Replied by Jo on topic Re: K2 on multilanguage sites
Hi,

I am also trying to get this to work!

The Twitter button changes automatically into other languages but I cannot get the facebook text to change.

I must be putting in the the code wrong :blush:

Any help appreciated!

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago - 11 years 11 months ago #113449 by Jo
Replied by Jo on topic Re: K2 on multilanguage sites
WOOHOOO!

Finally got it to work. Thank you Yiota for pointing me in the right direction.

I hope this helps someone else.

NOTE: This is for a 4 language site with spanish being the default language and catalan, english and french as the other languages so you will have to alter language codes and remove the blocks that you don't want. the default language is in the last block after the <?php else: ?>

First I added

$lang = JFactory::getLanguage();
$locale = $lang->getTag();

Right under
defined('_JEXEC') or die;

near the top of item.php

Then find the code between

<div id="fb-root"></div>
and
<div class="fb-like" data-send="false" data-width="200" data-show-faces="true"></div>

at around line 320 and replace the code with this



<?php if ($locale=='es-ES'): ?>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/es_ES/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<?php endif; ?>
<?php if ($locale=='ca-ES'): ?>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/ca_ES/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<?php endif; ?>
<?php if ($locale=='fr-FR'): ?>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/fr_FR/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

<?php else: ?>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<?php endif; ?>


I don't know if this is the correct way to do it but it works!

Please Log in or Create an account to join the conversation.

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 11 months ago #113450 by Filip Nikitovic
Replied by Filip Nikitovic on topic Re: K2 on multilanguage sites
I tried the same thing but it doesnt work.

Can You please paste Your item.php code here,just code between <!-- Facebook Button --> and <!-- Google +1 Button -->

It would help me a lot.

Please Log in or Create an account to join the conversation.

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 11 months ago - 11 years 11 months ago #113451 by Filip Nikitovic
Replied by Filip Nikitovic on topic Re: K2 on multilanguage sites
This is where I inserted

$lang = JFactory::getLanguage();
$locale = $lang->getTag();
<?php
/**
 * @version             $Id: item.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
 * @package             K2
 * @author              JoomlaWorks https://www.joomlaworks.net
 * @copyright   Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
 * @license             GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

// no direct access
defined('_JEXEC') or die;
$lang = JFactory::getLanguage(); 
$locale = $lang->getTag(); 
?>

Just as You did

Please Log in or Create an account to join the conversation.

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 11 months ago - 11 years 11 months ago #113452 by Filip Nikitovic
Replied by Filip Nikitovic on topic Re: K2 on multilanguage sites
<!-- Facebook Button -->
<div class="itemFacebookButton">
   <div id="fb-root"></div>
   <?php if ($locale=='de_DE'): ?> 
<script> 
(function(d, s, id) { 
var js, fjs = d.getElementsByTagName(s)[0]; 
if (d.getElementById(id)) return; 
js = d.createElement(s); js.id = id; 
js.src = "//connect.facebook.net/de_DE/all.js#xfbml=1"; 
fjs.parentNode.insertBefore(js, fjs); 
}(document, 'script', 'facebook-jssdk')); 
</script> 
<?php else: ?> 
<script> 
(function(d, s, id) { 
var js, fjs = d.getElementsByTagName(s)[0]; 
if (d.getElementById(id)) return; 
js = d.createElement(s); js.id = id; 
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; 
fjs.parentNode.insertBefore(js, fjs); 
}(document, 'script', 'facebook-jssdk')); 
</script> 
<?php endif; ?>                   
  <div class="fb-like" data-send="false" data-width="200" data-show-faces="true"></div>
   </div>
   <?php endif; ?>

Mybe You can see here what I did wrong

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #113453 by Jo
Replied by Jo on topic Re: K2 on multilanguage sites
Looks ok,
Are you sure you have added the languages in the content section of the language manager?

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
11 years 11 months ago #113454 by Yiota
Replied by Yiota on topic Re: K2 on multilanguage sites
The $locale of any language is not with an underscore put with a dash. What I mean is that instead of $locale=='de_DE' you should have $locale=='de-DE'.

Please Log in or Create an account to join the conversation.

  • Filip Nikitovic
  • Filip Nikitovic's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 10 months ago #113455 by Filip Nikitovic
Replied by Filip Nikitovic on topic Re: K2 on multilanguage sites
Hi,
Can be this done also for google+ button?

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum