Creating a multi-lingual site with localised URLs
This is an open discussion with 8 replies, filed under General.
Search
I’ve been looking forward to reading your method, I may have to do multilingual stuff very soon! Cheers!
Different Language domains
This is how removed the use of /fr/
URL parameters and instead set up a different domain per language.
- Obviously set up your domains/vhosts as required (example here).
- Keep the
Language Redirect
extension enabled, but do not use the Language Redirect event on any of your pages (this will force redirection using URL paramets, which we don’t want). You need to add some custom
.htaccess
rules to “inject” the/fr/
param behind the scenes, depending on the domain being used by the client. Mine looks something like this, added at the very beginning of the file (before the Symphony stuff):<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / # Redirect when in wrong domain RewriteCond %{HTTP_HOST} my.site.com [NC] RewriteRule ^(fr)/.*$ http://my.site.$1 [L,R=seeother] RewriteCond %{HTTP_HOST} my.site.fr [NC] RewriteRule ^(en)/.*$ http://my.site.$1 [L,R=seeother] # English RewriteCond %{HTTP_HOST} my.site.com [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/symphony/.*$ RewriteRule ^(en/)?(.*)$ index.php?language=en®ion=&symphony-page=$2&%{QUERY_STRING} [L] # French / Francais RewriteCond %{HTTP_HOST} my.site.fr [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/symphony/.*$ RewriteRule ^(fr/)?(.*)$ index.php?language=fr®ion=&symphony-page=$2&%{QUERY_STRING} [L] </IfModule>
So far this seems to work for me, although I’m almost sure I’ll discover some particular case when it f’s up for me. Will update as necessary.
@jstar198
Can you post your fields in pages section? I try to recreate but at the moment i have much errors :-)
Great post! really explains a lot of what's possible with some thinking in Symphony! Thanks for posting. Would it still be possible without using Multilingual field and maybe use Page Tabs extension to organise languages just planning something a little different see?
I'm trying to multi language website and I have a question about links, I need this big structure right?
<a href="/{$current-lang}/{/data/plh-page/page/item[@lang=$current-lang]/@handle}/{titulo/item[@lang=$current-lang]/@handle}">
Thanks,
Something like this, yes.
Thanks @vladG !
Use
### LANGUAGE REDIRECT RULES start RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(de|en|es|fr)-?()?/(.*/?)$ index.php?fl-language=$1&fl-region=$2&symphony-page=$3&%{QUERY_STRING} [L] ### LANGUAGE REDIRECT RULES end
It's what I used on http://www.sante.de/en/
Create an account or sign in to comment.
This is a very condensed summary of the multi-lingual site I am building with Symphony. This post — as well as my site — is a work in progress, but I’m putting this here to help out anyone else who would like to create something similar.
Site requirements
http://my.site.com/en/my-amazing-page
http://my.site.com/fr/ma-page-detonnant
http://my.site.com/my-amazing-page
http://my.site.fr/ma-page-detonnant
.htaccess
file.How I achieved this
home
for the front page.static
for all other pages on the site, with URL paramspage1/page2/page3
(limiting my maximum page depth to 3 pages)./static
checked
)Pages
which contains a bunch of Multilingual Fields, including one forURL Handle
. Heirarchy is “achieved” with a Parent Page field (using Select Box Link).A datasource called
Page
which uses thePages
section with the followingURL Handle
filter:{$page3}, {$page3}{$page2}, {$page3}{$page2}{$page1:home}
In my templates I can then just access
/data/page/entry
and use normally.Pages
, grouped byParent page
. Then some fancy XLST to display them in a nested fashion (recursively).