Multilingual web site

Post links to sites running CMS in all its glory.
katon

Multilingual web site

Post by katon »

This web site has been made with the multilingual modification of CMSMadeSimple:
http://nishiobudo.org.ua
Oliver
Forum Members
Forum Members
Posts: 28
Joined: Wed Mar 15, 2006 9:50 pm

Re: Multilingual web site

Post by Oliver »

That's terrific! Being able to produce multilingual sites is a top priority for CMS ms as for me. How did you do this one? I wish there were a simple module...
katon

Re: Multilingual web site

Post by katon »

I was using this hack:
http://dev.cmsmadesimple.org/projects/multilang/
It's a temporary solution.  Make sure to read the readme file before the install.
lennon
Forum Members
Forum Members
Posts: 88
Joined: Fri Jan 13, 2006 12:19 pm

Re: Multilingual web site

Post by lennon »

That looks great. Nice one Katon.
ealfert

Re: Multilingual web site

Post by ealfert »

Katon,

Thank you for the great code.  I needed multilanguage support.

If I turn on search engine friendly urls the navigation stops workings.

The system chokes on the "&lan=en" appended to the "page_name.html".

If you have the time and desire, would it be possible to make multilang work with the following format? 
http://www.domain.tld/en/page_name.html
http://www.domain.tld/es/page_name.html
http://www.domain.tld/au/page_name.html

Either way, thank you for the great code.

Edward
tamlyn

Re: Multilingual web site

Post by tamlyn »

ealfert wrote: If I turn on search engine friendly urls the navigation stops workings.

The system chokes on the "&lan=en" appended to the "page_name.html".
Surely that's just a matter of updating the rewrite rule in the .htaccess. I'll prob be using this mod for a site so I'll look into it and post back.
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Multilingual web site

Post by tsw »

Code: Select all

RewriteRule ^(.+)/(.+)\.html$ index.php?page=$2&lan=$1 [QSA]
UNTESTED as I dont have the mod installed...

EDIT: lang -> lan as katon said :)
Last edited by tsw on Sun Apr 09, 2006 10:48 am, edited 1 time in total.
katon

Re: Multilingual web site

Post by katon »

It's not lang, it's lan.
ealfert

Re: Multilingual web site

Post by ealfert »

Tamlyn, thanks for the effort and time you put into it.

But, it does not seem to work.  Gives a 404 error like the original rewriterule.
ealfert

Re: Multilingual web site

Post by ealfert »

I have played around with your rule by learning a little more about mod_rewrite and got it to work when the link contains both the page name and a language selection (test.html&lan=en).  NO MORE 404s!!!

RewriteRule ^(.+)\.html&lan=(.+)$ index.php?page=$1&lan=$2 [QSA]

But if the link only contains the page name (test.html) then it gives a 404.

It seems that the rule is matching only when both variable are present in the requested url.  Maybe the rule needs to be split in 2 so that it tests each component individually an matches one, the other, or both and the rewrite then rewrites only the parts that match instead of none?

Also,
tamlyn

Re: Multilingual web site

Post by tamlyn »

heh, i haven't put any effort or time into it! I think you emant to thank katon & tsw. Anyway this rewriterule should work better:

Code: Select all

RewriteRule ^(.+)\.html(&lan=.+)?$ index.php?page=$1$2 [QSA]
ealfert

Re: Multilingual web site

Post by ealfert »

OK...IT WORKS!

RewriteRule ^(.+)\.html(&lan=.+)?$ index.php?page=$1$2 [QSA]

But just before you gave me the elegant solution, I came up with a working ugly solution also... splitting into 2 rules.

RewriteRule ^(.+)\.html&lan=(.+)$ index.php?page=$1&lan=$2 [QSA]
RewriteRule ^(.+)\.html$ index.php?page=$1 [QSA]

Your rule is better and I will use it instead.

Now I notice another issue.  The links in the menu are friendly "http://www.domain.tld/test.html&lan=en", but the links for the flags to switch language are in the non-friendly format "http://www.domain.tld/index.php?page=test&lan=es".
ealfert

Re: Multilingual web site

Post by ealfert »

TSW,

Sorry I didn't give you thanks for the original rewriterule that got the ball rolling.  My bad.

(1) Mod_Rewrite is now working as it should and it looks to me that the issue I mentioned in my previous post...
Now I notice another issue.  The links in the menu are friendly "http://www.domain.tld/test.html&lan=en", but the links for the flags to switch language are in the non-friendly format "http://www.domain.tld/index.php?page=test&lan=es".
is not a mod_rewrite problem but a multilang design decision.  Katon, please correct me if I'm wrong.

(2) Also, fixing (1) above would be good but my ideal look for the URL would be in the format:
http://www.domain.tld/en/page.html
http://www.domain.tld/es/page.html
insead of:
Instead of the current"
http://www.domain.tld/page.html?lan=en
http://www.domain.tld/page.html?lan=es

I'm going to look at the code to see if i can figure it out.  Thanks everyone for your time.

Katon, is it as simply editing "modules/MenuManager/MenuManager.module.php" and finding the line that reads:
$onenode->url = $content->GetURL() . "&lan=$lan";

and changing it to:
$onenode->url = "$lan/" . $content->GetURL();

And then changing the mod_rewrite rules to look for the new format of URL?

Are there other php scripts or other areas that need to change other than MenuManager.module.php?
ealfert

Re: Multilingual web site

Post by ealfert »

For those that are interested in the format:
http://www.domain.tld/2LeterLanguageCode/page.html
The the following is working for me:

(1) Modify rewriterule in .htaccess to:
RewriteRule ^(.+)/(.+)\.html$ index.php?page=$2&lan=$1 [QSA]

(2) Modify "function GetURL" in "lib/classes/class.content.inc.php" by adding:
        global $lan;
Before the line that reads:
        global $gCms;

(3) Modify "function GetURL" in "lib/classes/class.content.inc.php" by changing:
            $url = $config["root_url"]."/".$alias.
to
            $url = $config["root_url"]."/".$lan."/".$alias

(4) Modify "" in "modules/MenuManager/MenuManager.module.php" by changing:
            $onenode->url = $content->GetURL() . "&lan=$lan";
to
            $onenode->url = $content->GetURL();

Now the Menu system creates the link format that I like and the mod_rewrite interprets it correctly.

The only issue remaining is the URLS that the flags hyperlink to.  I need to find the script that controls them and modify it.
katon

Re: Multilingual web site

Post by katon »

Please try 0.12.2 multilingual beta 1.  I didn't have a chance to test it it on multiple systems, so I need your help with this guys.
Post Reply

Return to “CMS Show Off”