Multilanguage Site

Permalink 3 users found helpful
Hi!

Internationalization and Localization is ready since August 25, 2009.

I've posted the code to the C5 Team, but they had not much time, due to the eCommerce block and the C5 5.3.3 Update.

However it'll hopefully go into the source in the next version.

If you need it asap, contact me.

Features:
- automatic country detection
- automatic locale detection
- one startpage that acts as any language automatically
- tld forwarding (.jp .de .us)
- subdomain forwarding de.example.org
- temporal forwarding (example.org/?lang=en)
- cookie remembers guests choice
- language switching by the hit of a flag
- works in the back- and frontend

TODO:
- multilang sitemap template
- automatic recognition of installed backend languages and offering an option to switch
- make switching the language in the backend look cooler
- plan an enterprise ready integration into the concrete5 back- and frontend

The information below is obsolete.
-----------------------------------------


Hi!

* Empty all content Blocks of your root document.
* Create a page called de_DE
* Create a page called en_US
* Now add Pages under those languages.

Example:

Home (root)
* de_DE (shorten url to "localhost/de")
- Home
- About
- Contact
* en_US (shorten url to "localhost/en")
- Home
- About
- Contact

Real world Example:
http://bit.ly/8BfqM (DE has one more entry, because the site has an interim page)

The ovious problem is that you get directed to the Home (root) first, when you visit localhost.

The solution is to add php code to geo-locate the IP (this is not always accurate), sniff for the browser language (you get >90% correct results) and if doesn't work for some reason , jump to your default language's path immediately.

If you're lazy you could simply add
<meta http-equiv="refresh" content="http://localhost/de/home">

to Home (root) which will automatically display your entry page in German.

It's clear that switching languages should always be possible, after the language detection. That's why you should add two flags on your site, which direct tohttp://localhost/de/home andhttp://localhost/en/home.

Don't forget to add a
<meta http-equiv="refresh" content="http://localhost/de/home">

to the de_DE page container in the Sitemap.
Do the same for the en_US page container but with /en/home in the meta url.

I hope this helps, the reason I didn't provide any code examples is that I'm just doing what I said :)

EDIT: It's much better to use something like
header("Location:".BASEURL."/de/");
instead of a meta refresh

If you need a great tutorial on howto realize a language detection, you should consider Stephanie's Blog athttp://bit.ly/oaol7

Best regards
Fernandos

Fernandos
View Replies:
Remo replied on at Permalink Reply
Remo
you should avoid these ugly meta tag redirects.

You can add some code to index.php that checks geoip or browser language and set PATH_INFO to the url you want to display.

$_SERVER['PATH_INFO'] = '/de/';
Fernandos replied on at Permalink Reply
Fernandos
Can't I just use:
header("Location:".BASEURL."/de/");
Remo replied on at Permalink Reply
Remo
but by doing this, you generate a second request which isn't necessary.. If your site has just a few hundred visitors per day you won't care, but if there are a few more it's a good thing to reduce everything you can.

It also doesn't change the url which some people might prefer.. Others not so much because you can have different pages by calling the same address. (an english one and a spanish or german one)
dom replied on at Permalink Reply
dom
Hey Remo,

we build some multi language sites and had to use this ugly meta redirects to change the first shown page. This way doesn't feel right.. it would be very nice if you could be a bit more explicit about your solution for this by setting the PATH_INFO..
Remo replied on at Permalink Reply
Remo
open index.php an add something like this:

$_SERVER['PATH_INFO'] = '/my-sub-home';


if you add this line before the dispatcher gets included you'll only see one page because .htaccess won't be able to set PATH_INFO (you would override it all the time).

Add some if's and else's and you're done (:
dom replied on at Permalink Reply
dom
Hi Remo,

thanks for your answer.. we tried to set the PATH_Info as you said, but we ran into the problem that we can't open the edit-mode anymore...
tishma replied on at Permalink Reply
this is not helping me either. with or without nice URLs turned on, /index.php/ part appears in some of the css and js locations, and they are not loaded. otherwise - yes, it finds the right page. maybe it has to do with theme?
tishma replied on at Permalink Reply
OK. Here is how I've fixed it:
if($_SERVER['REQUEST_URI'] == '/'){ //i.e. only if we're requesting homepage
   $_SERVER['PATH_INFO'] = '/defaultlanghome';
}

I'll try to do geoip stuff and hopefully post that as well.
Dutchwave replied on at Permalink Reply
Dutchwave
http://www.js-vault.us/iscripts/004.html
Fernandos replied on at Permalink Reply
Fernandos
Hi, Dutchwave and Remo!
I finished my work, it's not Javascript, but PHP which is more reliable.

I've currently a hacky setup, and have never written a C5 Block, but it shouldn't be hard. So I'll release a block for language-detection and redirection soon, as I finish my corp. project here.
Should be next week.

Cheers
Fernandos

EDIT: haha next week :D a corp project finishes never.. I shoulda know that :P
It's not a block! But a couple of php files and libraries.
dekelly replied on at Permalink Reply
dekelly
I have a bilingual site - English and Japanese. espmasia.com. (Japanese pages are not linked yet - add /index.php/jp

At the moment the links in footer.php are in English and point to the English pages. I need to have a different footer for the japanese pages only. How/where do I write the code so that the correct footer links are displayed for the corresponding languages?

Yoroshiku! Danii
dekelly replied on at Permalink Reply
dekelly
I'm thinking I need to create another file called footer_jpns.php

Then create a new set of page types for the Japanese site, renamed with a "_jpns" extension and change the footer include at the bottom of each page type.

Will try this anyway. If there's a guru way, let me know!
frz replied on at Permalink Reply
frz
you might consider keeping your page types functional, and have a US/JP theme instead. You could basically take all the files from one and copy them to the other.. you could even have core elements you included in both.

This should make it really easy to extend what your site can do by adding page types, and then just make sure you translate the interface from one theme to the other.

Once you pick a different part of your theme for an area on the site, all the pages below it will follow that theme. If you set things up right from the get go, this should all be pretty simple to manage.
Fernandos replied on at Permalink Reply
Fernandos
no, It's pretty easy.
just compare a session variable's content and do something.
alemao replied on at Permalink Reply
alemao
hi fernandos
have you finished this block now? would be interested in using it.
thanks
Fernandos replied on at Permalink Reply
Fernandos
hi alemao!

It's not a block, because it a bit more complex. However usage is easy, if you understand how it works.

If you need it asap, you can contact me and I'll try to help you.
segro replied on at Permalink Reply
hi fernandos,
i'm also very intersted in the multi-language detection. could you please post your final solution here? would be very nice.. thanks!
dbleisch replied on at Permalink Reply
dbleisch
I am very curious about this solution aswell. Any chance to get your examplecode?
frz replied on at Permalink Reply
frz
What's been going on is a lot of alpha ideas and different approaches that have up sides and down sides.. There isn't really a shrinkwrapped solution that would work for everyone in sight yet..

-frz
phazerz replied on at Permalink Reply
Yes ! please Fernando would you send me the code of your multi-language system. You can't imagine how much I really need that for my job at the moment.
Thank you very much for the great work ;-)
Best'
--phazerz
Fernandos replied on at Permalink Reply
Fernandos
I'm sorry, but as Franz stated before, the code I've written is not ready for the public and so not production ready.

But I can try to help you, if you want to.
pm me your e-mail^
segro replied on at Permalink Reply
Hi @all,
i visit this post every few weeks, but it seems to be dead.

Has anybody found a real production ready solution for the mulit-language approach with concrete5?

thanks in advance... Sebastian
Remo replied on at Permalink Reply
Remo
there's a lot of stuff going on in the subversion. It uses a completely different approach (compared to what Fernandos did) but I prefer it because it's simpler..

Probably in 5.4 (but I'm not a core team member, no promises from my side possible)
eca replied on at Permalink Reply
Hi,

C5 really really rocks! I've just got it and I'm loving it!

However, multilingual stuff is makings things hectic for me.

Remo: Is there any documentation about the stuff in SVN you mentioned?

Thanks
cssninja replied on at Permalink Reply 1 Attachment
cssninja
I had problem with multilanguage site, but I solved it this way:
I had to do website in 4 languages.
I created 4 main directories:

Home
|--eng
|---about
|---offer
|---news
|---contact
|--de
|--pl
|--ru

In every lang. directory it's the same subpages (about, offer, etc.).
For main directories I added new attribute, which allows to display image menu.
This menu displays the flags and redirects to the appropriate languages.
On every pages are header nav too, but display second level.
And when I go to the site in some main directory (eg. offer in english version), the flag is highlighted.
Problem with the Home, I solved in .htaccess.
I add DirectoryIndex index.php/eng and my default site is eng.
And everything works very well.
Fernandos replied on at Permalink Reply
Fernandos
hi CSSNinja!

Btw I like ya nick, especially because I like css much.

However your approch might work, but it's causing an additional request on every page view, via htaccess. htaccess files are generally performance eaters, that's why you shouldn't use htaccess where possible and copy the configuration into your httpd.conf or a subconfiguration file instead.

An easy and decent way of creating a multilanguage site, as I did is using condidtional content areas in your theme.

And you need to create and hook a language_detection file, which you migh copy into your tools (not concrete/tools) folder. After that you have to call that file on_before_render in example. Though it's easier to create a custom navigation and load that file from there.

I just didn't release my script, because c5 will bring out it's own multilanguage support and supporting two different approaches is bad. Though it's available for those who are in the beta team (beware, it's probably the longest thread in this forum).

;)
katz515 replied on at Permalink Reply
katz515
This is what I did for

http://www.jffla.org/2010/


<?php
      // get current cPath and replace /ja to /en
         $jfflapagevieworiginal = View::getViewPath();
         $jfflapageviewreplaced = str_replace ('/en', '/ja', $jfflapagevieworiginal);
      ?>
      <p align="center">
         <a href="<?php echo BASE_URL . DIR_REL . $jfflapageviewreplaced ?>/">Japanese</a></p>
simonh replied on at Permalink Reply
Did this ever get released?
Fernandos replied on at Permalink Reply
Fernandos
Yes, it's been in the beta forums available for a long time now.
But you should usehttp://www.concrete5.org/marketplace/addons/internationalization/... to get basic multilanguage features working. If you need more than that there is an expensive addon made by the core Team. You don't neccessarily need it though.
xara replied on at Permalink Reply
hi!i have a question.
in the option multilingual shows me this:"You don't have any interface languages installed. You must run concrete5 in English."
maybe i do something wrong...where i have to put my multilingual folder?in the folder"languages",right? i would appreciate an answer from you because i am really confused.thanks