💾 Archived View for chirale.org › 2008-07-13_119.gmi captured on 2024-07-08 at 23:19:11. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

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://en.example

http://it.example

Now, on http://example/ (your localhost server name for this site)

http://example/

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:

Internationalization module

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.

https://web.archive.org/web/20080713000000*/http://example.com/en

to language subdomains (<a href=

https://web.archive.org/web/20080713000000*/http://en.example.com

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 &#8220;sites/example.com&#8221; 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 &#8220;localhost&#8221; 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>&lt;VirtualHost *&gt;<br /> ServerName <strong>example</strong><br /> DocumentRoot /var/www/example.com/public_html/drupal6/<br /> &lt;Directory &#8220;/var/www/example.com/public_html/drupal6/&#8221;&gt;<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 /> &lt;/Directory&gt;<br /> &lt;/VirtualHost&gt;</p> <p>&lt;VirtualHost *&gt;<br /> ServerName <strong>it.example</strong><br /> DocumentRoot /var/www/example.com/public_html/drupal6/<br /> &lt;Directory &#8220;/var/www/example.com/public_html/drupal6/&#8221;&gt;<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 /> &lt;/Directory&gt;<br /> &lt;/VirtualHost&gt;</p> <p>&#8230;</p></blockquote> <p>Now visit <a href=

https://web.archive.org/web/20080713000000*/http://en.example

and <a href=

https://web.archive.org/web/20080713000000*/http://it.example

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/web/20080713000000*/http://example/

(your localhost server name for this site)</p> <ol> <li>go to Admin &gt; Languages &gt; Configure</li> <li>set Language negotiation to <strong>Domain name only</strong></li> <li>Save settings</li> <li>go to Admin &gt; Languages &gt; 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/web/20080713000000*/http://en.example

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/web/20080713000000*/http://drupal.org/project/i18n

https://web.archive.org/web/20080713000000*/http://it.example/wiki/Ritsuko_Akagi

<li><a href=

https://web.archive.org/web/20080713000000*/http://en.example/wiki/Ritsuko_Akagi

</ul> <p>That&#8217;s all.</p>