Wiki style: multilingual subdomain on 6.x
Drupal x comes with some nice multilingual features: I want to use these to transform my multilingual website from “prefix path” (http://example.com/en) to language subdomains (http://en.example.com). I like this method on Wikipedia, so it will be a nice additions to my Drupal wiki site.
=> http://example.com/en
=> http://en.example.com
Prerequisites:
* Drupal x (tested on Drupal x)
* A sites/default directory with a settings.php file pointing to your database (locally). You can alternatively create one “sites/example.com” directory on production website. Setting for subdomains will be read here.
If you want to test this on your local machine before any production use, change your /etc/hosts file adding near “localhost” your language subdomains (I will use english\* and italian\*).
1 localhost example en.example it.example
Go to your Apache configuration (usually /etc/apache2/sites-available/default) and copy your local configuration for each server name (copy and change bold declaration, eg. example it.example en.example).
Note: skip this step if you want to configure subdomains. I use this configuration on my local test machine, but I use subdomains (configured via CPanels) on production website.
\<VirtualHost \*\>
ServerName example
DocumentRoot /var/www/example.com/public_html/drupal6/
\<Directory “/var/www/example.com/public_html/drupal6/”\>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from 0/0 ::1/128
\</Directory\>
\</VirtualHost\>
\<VirtualHost \*\>
ServerName it.example
DocumentRoot /var/www/example.com/public_html/drupal6/
\<Directory “/var/www/example.com/public_html/drupal6/”\>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from 0/0 ::1/128
\</Directory\>
\</VirtualHost\>
…
Now visit http://en.example and http://it.example. You should login to these site before proceed, otherwise you cannot set a language URL.
http://it.example (http://it.example)
Now, on http://example/ (your localhost server name for this site)
go to Admin \> Languages \> Configure set Language negotiation to Domain name only Save settings go to Admin \> Languages \> List and edit a language (you may have to enable it with add language) On Language domain for english type . Do the same (with it subdomain) on Italian language configuration.
Now you can download and install Internationalization module. After that:
Go to Admin \> Content types \> Your-content-type (tipically Page or similar) On Workflow settings select Enabled, with translation
Now, create a page selecting “English” as language. Save it and go to Translate tab, then add a translation in the other language. On the bottom of the page you can see a language switcher. Click on it and watch your URL.
If you use Path alias (and/or Pathauto module) you can use the same alias for any subdomain. Why? Because {url_alias} table comes with a nice “language” field. If I want to have two different articles about Ritsuko Akagi, one in English and the other in Italian, using the same path alias, my database table {url_alias} will contains:
pid src dst language 6 node/3 wiki/Ritsuko_Akagi it 8 node/4 wiki/Ritsuko_Akagi en
For:
*
*
That’s all.
to language subdomains (<a href= (https://web.archive.org)
https://web.archive.org/web/20080713000000*/http://en.example.com (https://web.archive.org)
I like this method on Wikipedia, so it will be a nice additions to my Drupal wiki site.</p> <p>Prerequisites:</p> <ul> <li>Drupal 6.x (tested on Drupal 6.x)</li> <li>A sites/default directory with a settings.php file pointing to your database (locally). You can alternatively create one “sites/example.com” directory on production website. Setting for subdomains will be read here.</li> </ul> <p>If you want to test this on your local machine before any production use, change your <strong>/etc/hosts</strong> file adding near “localhost” your language subdomains (I will use <strong>en</strong>glish* and <strong>it</strong>alian*).</p> <p>127.0.0.1 localhost example en.example it.example</p> <p>Go to your Apache configuration (usually /etc/apache2/sites-available/default) and copy your local configuration for each server name (copy and change <strong>bold</strong> declaration, eg. example it.example en.example).<br /> <strong>Note: skip this step if you want to configure subdomains. I use this configuration on my local test machine, but I use subdomains (configured via CPanels) on production website.</strong></p> <p><VirtualHost *><br /> ServerName <strong>example</strong><br /> DocumentRoot /var/www/example.com/public_html/drupal6/<br /> <Directory “/var/www/example.com/public_html/drupal6/”><br /> Options Indexes FollowSymLinks MultiViews<br /> AllowOverride All<br /> Order allow,deny<br /> allow from 127.0.0.0/255.0.0.0 ::1/128<br /> </Directory><br /> </VirtualHost></p> <p><VirtualHost *><br /> ServerName <strong>it.example</strong><br /> DocumentRoot /var/www/example.com/public_html/drupal6/<br /> <Directory “/var/www/example.com/public_html/drupal6/”><br /> Options Indexes FollowSymLinks MultiViews<br /> AllowOverride All<br /> Order allow,deny<br /> allow from 127.0.0.0/255.0.0.0 ::1/128<br /> </Directory><br /> </VirtualHost></p> <p>…</p></blockquote> <p>Now visit <a href= (https://web.archive.org)
https://web.archive.org/web/20080713000000*/http://en.example (https://web.archive.org)
and <a href= (https://web.archive.org)
https://web.archive.org/web/20080713000000*/http://it.example (https://web.archive.org)
You should login to these site before proceed, otherwise you cannot set a language URL.</p> <p>Now, on <a href= (https://web.archive.org)
https://web.archive.org/web/20080713000000*/http://example/ (https://web.archive.org)
(your localhost server name for this site)</p> <ol> <li>go to Admin > Languages > Configure</li> <li>set Language negotiation to <strong>Domain name only</strong></li> <li>Save settings</li> <li>go to Admin > Languages > List and <strong>edit</strong> a language (you may have to enable it with add language)</li> <li>On <strong>Language domain</strong> for english type <strong><a href= (https://web.archive.org)
https://web.archive.org/web/20080713000000*/http://en.example (https://web.archive.org)
Do the same (with it subdomain) on Italian language configuration.</li> </ol> <p>Now you can download and install <a href= (https://web.archive.org)
https://web.archive.org/web/20080713000000*/http://drupal.org/project/i18n (https://web.archive.org)
https://web.archive.org/web/20080713000000*/http://it.example/wiki/Ritsuko_Akagi (https://web.archive.org)
<li><a href= (https://web.archive.org)
https://web.archive.org/web/20080713000000*/http://en.example/wiki/Ritsuko_Akagi (https://web.archive.org)
</ul> <p>That’s all.</p> (https://web.archive.org)
Response: 20 (Success), text/gemini
| Original URL | gemini://chirale.org/2008-07-13_119.gmi |
|---|---|
| Status Code | 20 (Success) |
| Content-Type | text/gemini; charset=utf-8 |