Multiple languages
Permalink 1 user found helpful
Hi there
I know, it's quiet a old question, but after sarching the forum and community pages, i've found that there seem to be no solutions ...yet. Please let me describe what I would like to do in brief with Concrete 5:
I have a Website in german language by default. Now there should be to two buttons on the site: [DE] | [EN] letting the visitor switch between german and english language.
My question is: Is it possible to realize such a feature without tweaking C5?
Many thanks.
I know, it's quiet a old question, but after sarching the forum and community pages, i've found that there seem to be no solutions ...yet. Please let me describe what I would like to do in brief with Concrete 5:
I have a Website in german language by default. Now there should be to two buttons on the site: [DE] | [EN] letting the visitor switch between german and english language.
My question is: Is it possible to realize such a feature without tweaking C5?
Many thanks.
http://apostolides.yliassis.com/
What i did was to create autonav and make a custom template. See the website i did, also what i need to change is when the person clicks on a different language to change it to the current translation of that page. that would be a good feature. :)
Remo can help me with it, right Remo?
;)
please??? :)
What i did was to create autonav and make a custom template. See the website i did, also what i need to change is when the person clicks on a different language to change it to the current translation of that page. that would be a good feature. :)
Remo can help me with it, right Remo?
;)
please??? :)
I'm afraid, this isn't easy to "fix"..
It's not a big problem for me. I've got a few sites with this feature (not c5 sites thou) and I analyzed a few things. It almost never happened that a user change the language after he viewed 10 pages.. People tend to realize quite quickly that they don't understand russian and switch the language right after the first page view.. I therefore don't care about that anymore..
What you could do:
1. Link pages. Create an attribute which allows you to link all the pages. Specify a "main language" and all other language pages are connected to their main language page.. You could then create a little script to fetch this connection. Ugly to maintain
2. Name all pages the same way /de/product/ and /en/product/ and /gr/product/. Use some javascript.. Easy but stupid (SEO etc.)
But what happens if a page hasn't been created in a certain language? uhm..
C5 doesn't allow you to have one page object with different content for each language. The database model isn't built for this..
Fernandos did some nice work about this, but it makes things quite complicated imho. Search after his name, you should find his stuff here..
It's not a big problem for me. I've got a few sites with this feature (not c5 sites thou) and I analyzed a few things. It almost never happened that a user change the language after he viewed 10 pages.. People tend to realize quite quickly that they don't understand russian and switch the language right after the first page view.. I therefore don't care about that anymore..
What you could do:
1. Link pages. Create an attribute which allows you to link all the pages. Specify a "main language" and all other language pages are connected to their main language page.. You could then create a little script to fetch this connection. Ugly to maintain
2. Name all pages the same way /de/product/ and /en/product/ and /gr/product/. Use some javascript.. Easy but stupid (SEO etc.)
But what happens if a page hasn't been created in a certain language? uhm..
C5 doesn't allow you to have one page object with different content for each language. The database model isn't built for this..
Fernandos did some nice work about this, but it makes things quite complicated imho. Search after his name, you should find his stuff here..
Hi vnikos and Remo
Many thanks for your kind and quick replies. I'm working right now on a site with two languages. Will post my experiences here very soon...
Many thanks for your kind and quick replies. I'm working right now on a site with two languages. Will post my experiences here very soon...
Here is my solution. I'm sure it's nothing new for the C5 cracks in this forum :-) but anyway, i'm publishing it; maybe it's helpful for others. The solution is useful for small websites that need to be displayed in different languages. It's lets the visitor choose the language by clicking a link like [de] or [en] on the site.
First, there needs to be created a Main page for every language directly beneath the Homepage. Second, the language specific topic pages are created under the language main pages. See the sitemap example attached to this posting. This method has one important advantage: it let's the user chose a language directly when calling the site. For example:http://www.example.com/en.
For every page, the Autonav bar needs to be modified. Set the option "Display pages" to "at the second level". This makes sure that not the language main pages but the specific topic pages are displayed in the navigation.
After doing this, a decision must be made: There exists the "Home" page which is displayed first when opening the website without additional path or cID. This page can be used to display a nice language selector. But - as for me - i don't like this "intro" or "channel" pages, i prefer to go directly to the needed information.
As a result, i created a redirector for the Home page. To use the following example, the "Pretty URL" feature (Sitewide Settings) must be enabled.
It redirects a call to "www.example.com" to a default language main page. Due to I live in Switzerland, i defaulted the site to german. Therefore a request tohttp://www.example.com redirects tohttp://www.example.com/de. There are two possibilities to do this:
A. Use PHP and add a few lines at the beginning of your template file (i.e. default.php). The beginning of my default.php looks like this:
(Maybe there is a better method for PHP redirecting in C5, please let me know if you have one)
B. Using Apache:
Just put a RewriteRule in your .htaccess file
The multilingual site is already working now. To let the user choose between languages at any time, put links on the site:
de:http://www.example.com/de
en:http://www.example.com/en
...
That's all of it. It works fine for me, thanks to Concrete 5! The working site can be found in my user's profile.
First, there needs to be created a Main page for every language directly beneath the Homepage. Second, the language specific topic pages are created under the language main pages. See the sitemap example attached to this posting. This method has one important advantage: it let's the user chose a language directly when calling the site. For example:http://www.example.com/en.
For every page, the Autonav bar needs to be modified. Set the option "Display pages" to "at the second level". This makes sure that not the language main pages but the specific topic pages are displayed in the navigation.
After doing this, a decision must be made: There exists the "Home" page which is displayed first when opening the website without additional path or cID. This page can be used to display a nice language selector. But - as for me - i don't like this "intro" or "channel" pages, i prefer to go directly to the needed information.
As a result, i created a redirector for the Home page. To use the following example, the "Pretty URL" feature (Sitewide Settings) must be enabled.
It redirects a call to "www.example.com" to a default language main page. Due to I live in Switzerland, i defaulted the site to german. Therefore a request tohttp://www.example.com redirects tohttp://www.example.com/de. There are two possibilities to do this:
A. Use PHP and add a few lines at the beginning of your template file (i.e. default.php). The beginning of my default.php looks like this:
(Maybe there is a better method for PHP redirecting in C5, please let me know if you have one)
B. Using Apache:
Just put a RewriteRule in your .htaccess file
The multilingual site is already working now. To let the user choose between languages at any time, put links on the site:
de:http://www.example.com/de
en:http://www.example.com/en
...
That's all of it. It works fine for me, thanks to Concrete 5! The working site can be found in my user's profile.
what I would do is put the Home, the root, make it to not appear in the autonav, so the user will not have the homepage later on on their browsing. To make it better with SEO, as Remo suggested, I would do a sort of redirecting with page attributes like for
English page pageAttribute["pathToEn"]->"about-us"
for Russian page pageAttribute["pathToEn"]->"about-us"
["handle"]->Russian translation of about us
and implement the autonav thing with that sense, never tried to though, but it shouldn't be that hard to implement, but maintaining it without code to create those attributes will be a b1tch.
English page pageAttribute["pathToEn"]->"about-us"
for Russian page pageAttribute["pathToEn"]->"about-us"
["handle"]->Russian translation of about us
and implement the autonav thing with that sense, never tried to though, but it shouldn't be that hard to implement, but maintaining it without code to create those attributes will be a b1tch.
also one could write to session and then switch upon that value, if present, for areas or whatever.
What I mean is in your template:
$cp = new Permissions($c);
if($cp->canWrite() ){ //canAddSubContent, canAdmin(), whatever you want to use as a check
//render both areas.
$a = new Area('lolcats');
$a->display($c);
$a = new Area('normal');
$a->display($c);
}
}
//visitors
if($_SESSION['language'] == 'lolcats'){
$a = new Area('lolcats');
$a->display($c);
}else{
$a = new Area('normal');
$a->display($c);
}
I dunno, just an idea?
What I mean is in your template:
$cp = new Permissions($c);
if($cp->canWrite() ){ //canAddSubContent, canAdmin(), whatever you want to use as a check
//render both areas.
$a = new Area('lolcats');
$a->display($c);
$a = new Area('normal');
$a->display($c);
}
}
//visitors
if($_SESSION['language'] == 'lolcats'){
$a = new Area('lolcats');
$a->display($c);
}else{
$a = new Area('normal');
$a->display($c);
}
I dunno, just an idea?
good idea ;) I did it similar^
but I've put all that area stuff into a library so I only need to call Content:i8n("Content,Inhalt,Contenuto,Contenu"); and it'll add areas etc. the rest is magic xD
but I've put all that area stuff into a library so I only need to call Content:i8n("Content,Inhalt,Contenuto,Contenu"); and it'll add areas etc. the rest is magic xD
You can try to make the code more generic and use the "replace_link_with_first_in_nav" attribute. You only have to add this attribute for your homepage and activate it. Then add this code to default.php.
Now every time you try to view a page that has "replace_link_with_first_in_nav" the first child will be displayed instead.
$nh = Loader::helper('navigation'); if ($c->getCollectionAttributeValue('replace_link_with_first_in_nav')) { $subPage = $c->getFirstChild(); if ($subPage instanceof Page) { $pageLink = $nh->getLinkToCollection($subPage); header ("HTTP/1.1 301 Moved Permanently"); header ("Location: ".$pageLink); exit(); } }
Now every time you try to view a page that has "replace_link_with_first_in_nav" the first child will be displayed instead.
Hi
Is there a way to then include the second home on the navigation?
i.e.
|sitehome
|-en(home)
|--page1
|--page2
|-de(home)
|--page1
|--page2
So auto nav displays:
home page1 page2
Thanks
Is there a way to then include the second home on the navigation?
i.e.
|sitehome
|-en(home)
|--page1
|--page2
|-de(home)
|--page1
|--page2
So auto nav displays:
home page1 page2
Thanks
Hi, Thanks for that, however I had seen that.
I guess I need to clarify what i'm trying to achieve...
1. When building a standard site, although the home page (/) isn't on the same level as the subpage (/subpage) they are both show in the autonav. How do I get the autonav to display a series of pages and their parent in the same way?
i.e. Home(/en) Subpage1(/en/subpage1) Subpage2 (/en/subpage2)
2. Can I use the pretty names solution somehow to skip past the initial Home page(/) and have the root default to (/en). or do I have to use .htaccess?
3. If I can't achieve 1. the i'll have to build the site (/en/home, /en/subpage1, etc.. /de/home, /de/subpage1, etc..) so can I use the same method as in 2. to skip / and /en to set the root as /en/home?
Thanks in advance for all your fantastic help!
I guess I need to clarify what i'm trying to achieve...
1. When building a standard site, although the home page (/) isn't on the same level as the subpage (/subpage) they are both show in the autonav. How do I get the autonav to display a series of pages and their parent in the same way?
i.e. Home(/en) Subpage1(/en/subpage1) Subpage2 (/en/subpage2)
2. Can I use the pretty names solution somehow to skip past the initial Home page(/) and have the root default to (/en). or do I have to use .htaccess?
3. If I can't achieve 1. the i'll have to build the site (/en/home, /en/subpage1, etc.. /de/home, /de/subpage1, etc..) so can I use the same method as in 2. to skip / and /en to set the root as /en/home?
Thanks in advance for all your fantastic help!
Create this structure
/de/
/de/produkt/
/de/
/en/product/
and add a content block on the homepage with two links..