- Posts: 73
COMMUNITY FORUM
K2 on multilanguage sites
- Filip Nikitovic
-
Topic Author
- Offline
- Senior Member
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
-
- Visitor
Please Log in or Create an account to join the conversation.
- Filip Nikitovic
-
Topic Author
- Offline
- Senior Member
- Posts: 73
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
-
- Visitor
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
-
Topic Author
- Offline
- Senior Member
- Posts: 73
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
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Moderator
- Posts: 8743
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
-
Topic Author
- Offline
- Senior Member
- Posts: 73
Is that normal?
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
Please Log in or Create an account to join the conversation.
- Filip Nikitovic
-
Topic Author
- Offline
- Senior Member
- Posts: 73
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
-
- Visitor
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
-
Topic Author
- Offline
- Senior Member
- Posts: 73
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
-
- Visitor
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.
- Jo
-
- Offline
- New Member
- Posts: 15
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.
- Jo
-
- Offline
- New Member
- Posts: 15
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
-
Topic Author
- Offline
- Senior Member
- Posts: 73
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
-
Topic Author
- Offline
- Senior Member
- Posts: 73
$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
-
Topic Author
- Offline
- Senior Member
- Posts: 73
<!-- 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.
- Jo
-
- Offline
- New Member
- Posts: 15
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
-
- Visitor
Please Log in or Create an account to join the conversation.
- Filip Nikitovic
-
Topic Author
- Offline
- Senior Member
- Posts: 73
Can be this done also for google+ button?
Please Log in or Create an account to join the conversation.