6.4 KiB
layout, status, published, title, author, author_login, author_email, author_url, wordpress_id, wordpress_url, date, categories, tags, comments
| layout | status | published | title | author | author_login | author_email | author_url | wordpress_id | wordpress_url | date | categories | tags | comments | |||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| post | publish | true | A simple way to get a multilingual blog | Julien Lengrand-Lambert | jlengrand | julien@lengrand.fr | http://www.lengrand.fr | 366 | http://www.lengrand.fr/?p=366 | 2011-12-12 13:55:52.000000000 +01:00 |
|
|
|
Some time ago, I searched for a way to have a blog as simple as possible (and avoid wordpress or joomla monsters). I ended up using Pluxml for a while, and you can find the result here.
One of the things I wanted absolutely was to write my blogs in several languages (french and english). After some time, I finally found a way to do it with a bit of javascript.
The main idea is simple : You get one div by language. On startup, only one div is shown, and a click on a "switch language" link shows the other div while making the first disappear.
You can see an example of the result here.
To do this, you need two things :
- Insert some javascript functions in your webpage. You can do this by importing a file, or simply copying the following code in your template:
{% highlight javascript %}
<script type="text/javascript">// </script>{% endhighlight %}
- Then, Write down your article in both languages, one after the other in you editor. Each language should be placed in a separate div; and a button placed to switch from one language to the other. Here is an example :
{% highlight javascript %}
Français / English
{% endhighlight %}
All you have to do now is to "beautify" the code by changing the link into a flag, and enhance the way div are displayed.The bad thing is you will have some javascript code in your articles, and both languages are present on the same page.There you are ! The "class = cachediv" is used to hide the on load.
Hope this help ;)
And if you have a better idea, please let me know !
[source]NOTE : Sorry for the code being in french (its not mine). I could take some time to translate it if you want :)Note: I have recently done some cleanup and the sample website is not available any more (It needs a server with PHP to run). However, you can find the source of the dark theme here.