Elxis CMS Forum

Support => Language => Topic started by: pavel on March 26, 2009, 15:44:03

Title: language smart switch
Post by: pavel on March 26, 2009, 15:44:03
Hello everybody. 

My site is in 4 languages and I'd like to have content dynamically switching between same content items in different languages.  I was successful in getting the BLOG CATEGORY to switch smartly (to show the list of items of a multilingual category published in one or another language), however, I seem to have a problem with getting the content item published in English to switch to the same content item published in Russian or Greek.

I was looking at the example of the latest link to IOS gallery component, it looks like two versions are published (in Greek and English for all other languages).

How can I get SAME section name, same category name and same content item name at the same time?  SEO naming rule says that there could be only one unique name for a section, one unique name for each category of the same section, and one unique name of the content item in each category.

I created the following structure on my site:

http://www.domain.com/section_one/category-en/article1.html
http://www.domain.com/ru/section_one/category-ru/article1.html

In this structure, section_one (multilingual) is a host to category-en (english only) and category-ru (russian only), and both content items - article1.html are published in english and russian language of the respective categories.

Elxis does not let me create two categories with the same name or two content items (of the same category) with the same name, but published in a different language......

I found following recommendations in forum for the smart switch:

- Have the "Smart switch" option enabled in the language module. (OK, ENABLED)
- Have mosConfig_sef = 0 (non-SEF URLs) or 2 (Elxis SEO pro). It does not work with old standard SEF. (SWITCHED TO 2)
- The current Itemid (selected menu item) is available for all languages or for the language you wish to switch to. (I am not sure I understood this one correctly - item itself is available, menu is available to, but paths are different as per information above).

So I am lost in translation....   So if anybody could help me, I would greatly appreciate.
Title: Re: language smart switch
Post by: datahell on March 26, 2009, 21:00:38
You can switch language and stay in the same page only if the following condition is fulfilled:
The currently selected menu item is available to the other language.
else you are redirected to the front-page.

Example
Let's consider you have the following menu:

Football results (link to section A, menu item available for languages: english, italian)
Αποτελέσματα ποδοσφαίρου (link to section A, menu item available for languages: greek)

Case 1: You have English as your currently selected language.
If you switch to Italian you stay at the same page.
If you switch to Greek you get redirected to the site's front-page.

Case 2: You have Italian as your currently selected language.
If you switch to English you stay at the same page.
If you switch to Greek you get redirected to the site's front-page.

Case 3: You have Greek as your currently selected language.
If you switch to English you get redirected to the site's front-page.
If you switch to Italian you get redirected to the site's front-page.

Section A needs to be available in both 3 language in the above example.

A different approach would be the following:

Football results (link to section A, menu item available for languages: english, italian)
Αποτελέσματα ποδοσφαίρου (link to section B, menu item available for languages: greek)

In Elxis Downloads Center the "Downloads" link is available for ALL languages. This is why you can switch to any language and stay at the same page. EDC also uses a custom top menu module for providing better navigation that translates on the fly the menu items. This way we have reduced the number of the required menu items to 5. But the real menu is the "Downloads" on your left hand. See that is always highlighted when you are on the downloads section.

Additional note: All of the standard Elxis menu items (system links) are multilingual by the Elxis core.
Additional help: http://wiki.elxis.org/wiki/Navigation_and_menus (http://wiki.elxis.org/wiki/Navigation_and_menus)
Title: Re: language smart switch
Post by: pavel on March 27, 2009, 15:33:06
Thank you for your reply.  I red all links on smart switch, but still can't understand how it works.
----

It appears that elxis-downloads.com has the following structure (in relation to IOS downloads page):

Section: com_downloads (multilingual)
 >    Category: image-galleries (multilingual)
   >>          Content item: 166.html (English + other published languages)
   >>          Content item: 166.html (Greek)

This is the address for English: com_downloads/image-galleries/166.html
This is the address for Greek: el/com_downloads/image-galleries/166.html

So when smart switch works, it looks for the same article 166.html in the same section/category, but published under a different language.

However, I can not save two different content items in the same category under the same SEO title.  There could be only one 166.html in any given category!?

....  ??? ....

Currently I have the following site structure:

Section1/   (All Languages)
 >Category1/ (ru)
   >>Article1.html (en)
 >Category2/ (ru)
  >>Article1.html (ru)

My current menu:
>Home (en)
>Home (ru)
>MenuItem2 (en) - blog category for Category1.
  >>Article1 (en) - link to content item Category1/Artile1.html
>MenuItem3 (ru) - blog category for category 2
  >>Article1 (ru) - link to content item Categor2/Article1.html

So MenuItem2 with its submenu should appear only in English, MenuItem3 with submenu should appear only in Russian.
When I am on page Article1 (en) I need to be able to jump to Article1 (ru) and back.

I tried various languages/names for categories and content items, but nothing seems to enable the switch to operate properly.   

Could you suggest content structure + menu structure for switching from article1.html (ru) to article1.html(en) and back. 

Many thanks.  I really appreciate your help.
Title: Re: language smart switch
Post by: datahell on March 27, 2009, 18:46:00
IOS Downloads is a component, it does not display content items but download listings.
It also does not have sections, just categories, or if you wish, the section is the component it self.

Smart language switch has to do with MENU items, NOT with CONTENT items.
Title: Re: language smart switch
Post by: jimmyz on March 28, 2009, 17:08:17
Smart language switch has to do with MENU items, NOT with CONTENT items.

That's clear enough for me, but what if I want to have the SAME menu item in different languages? In example "Downloads" for english, "αρχεία" in Greek and so on... Is this possible?
If I have two different menu items,"Downloads" and "αρχεία", Smart language switch doe not work.  ???
Title: Re: language smart switch
Post by: ks-net on March 28, 2009, 17:16:04
Quote
....In example "Downloads" for english, "αρχεία" in Greek and so on... Is this possible?
If I have two different menu items,"Downloads" and "αρχεία", Smart language switch doe not work.

answer is already given:

Quote
Football results (link to section A, menu item available for languages: english, italian) --->works
Αποτελέσματα ποδοσφαίρου (link to section A, menu item available for languages: greek)----> go to homepage

it is a smart switch not a wizard... to guess.
Title: Re: language smart switch
Post by: jimmyz on March 28, 2009, 17:28:07
Exactly!
Maybe in some next version of Elxis, menus could work as i.e., the downloads component: naming the item for Greek language and naming the item for English language.

(http://img9.imageshack.us/img9/4154/langsupport.jpg)
Title: Re: language smart switch
Post by: pavel on March 28, 2009, 17:38:48
The language smart switch is really complicated.  It is a very important feature of Elxis, which makes Elxis better than many other CMS.  That is why I would like to ask Elxis gurus to write a small tutorial with:

1)  sample content structure (with two content items in different languages)
2)  sample menu (that can show how elxis can switch from one content item to another and stay on the same page).

This can help everybody in future to understand and use elxis better.  Thank you.
Title: Re: language smart switch
Post by: ks-net on March 28, 2009, 18:08:53
i can see only 2 lang ...  the other 40 where they are? or at least the 6 lang that i use?

as pavel said.... things will be very complicated !

we all, knew that way ... but for now i think the way it works is  good enough!


Quote
1)  sample content structure (with two content items in different languages)
2)  sample menu (that can show how elxis can switch from one content item to another and stay on the same page).
they will be in elxis wiki....plus many other relative to multi-lang...   only have patience.
Title: Re: language smart switch
Post by: datahell on March 28, 2009, 19:33:44
Smart language switch works fine and based on the settings WE have made on the menus. It does not act by itself, it is not a magician and as ks-net said it can not guess our intentions.

Working with Elxis language system
The following example is just a sample, you should adapt it to your needs.

Consider that we have a menu item available for all languages (or for a group of languages). This menu item will link to section A which is available for all languages. Section A will contain separate categories available in English, Greek, Italian, etc languages.
Category A is available in English language and contains articles in English.
Category B is available in Greek language and contains articles in Greek.
Category C is available in Italian language and contains articles in Italian.

Alternative method: 1 category available for all languages contain articles in various languages.

Under any of the following cases you will have a good multilingual content and smart language switch will work fine:

The menu item is of type "Blog - Content Section" that links to section A.
The menu item is of type "Table - Content Section" that links to section A.

If we use the alternative method menu item could also be a link to the category:
Blog - Content Category
Table - Content Category

For the cases above smart language switch will work fine except from one point: the menu item title will stay at the same language (the one you entered in the menu item parameters). If you need to change that title when the language changes here is a trick:

Continue reading at your own risk

We can slightly modify the mainmenu module (or to what ever menu module we use) to create multilingual module titles regardless of the settings on the menu item parameters.

File: modules/mod_mainmenu.php
Function: getMenuLink

Find this:
$mitem->name = stripslashes(ampReplace($mitem->name));

Add bellow:

Code: (php) [Select]
<?php 
if ($mitem->id == &#39;XXX&#39;) { //where XXX the Itemid we are interested in
    
global $lang;
    switch (
$lang) {
        case &
#39;greek&#39;: $mitem->name = &#39;Ελληνικός Τίτλος&#39;; break;
        
case &#39;italian&#39;: $mitem->name = &#39;Titolo in Italiano&#39;; break;
        
case &#39;english&#39;: default: break; //leave the title as is for English and any other language
    
}
}
?>


You have to set the module's file encoding to utf-8 if you write hard coded multilingual text in it.
You can also do the same trick for other menu items (Itemid)

Additional note: Take a look also on the function translateMenu on the same file, you might get some nice ideas...
Title: Re: language smart switch
Post by: datahell on March 28, 2009, 19:38:02
We can not add the component's Downloads multilingual system (IOS Dialects technology) in Elxis because this will limit down the number of available languages (IOS Downloads accepts maximum 4 languages). It could be done using a separate database table that would hold the menu item names in each language but this requires hard Elxis modification. Notice that the menu system is something that is going to change in the future (2010).
Title: Re: language smart switch
Post by: pavel on March 28, 2009, 21:56:33
Thank you for a very detailed explanation. 
It is clear and it works.

Also it works for my case, where I can jump from content_item_en to content_item_gr directly, providing:
- they belong to the same category
- there are no other items in the same category
- the menu is a blog-category link (available in all languages - only one menu item is required; if published in 1 language only - one menu item is required for each language).

Needless to say, this is a very special case and it works only for content that is more or less static. 

Actually, it is extremely rare that content in different languages is exactly the same.  So for most cases display of content category containing many differnet items in different languages (as a blog or as a table) would be perfectly suitable.

Thanks again for your help and support.  It is really appeciated.
Title: Re: language smart switch
Post by: pavel on April 02, 2009, 16:35:14
PHP code above is really amazing way to switch between languages while staying on the same page.  Works perfectly for Contacts, News blog category menu and I am sure for many other cases.

I think it should become an inbuilt feature of Elxis, where a menu item could be given different titles, like in the IOS Gallery.  Meanwhile, this hack is good enough for me.

Thanks for sharing!
Title: Re: language smart switch
Post by: datahell on April 02, 2009, 21:24:35
Elxis has much more advanced code built in, but runs for system or other special purpose menu items. The menu items YOU enter are custom menu items and Elxis won't touch them. It is very easy to expand Elxis multilingualism. The above code is just a sample, I am happy that you found it useful.

Note: In Elxis 2009.0 a new language specific feature is introduced. First time visitors are get redirected automatically to a version of the site available to their local language (browser language detection).