Dear Sphinx developers, I'm trying to create a multilingual website using Sphinx, and I post my thoughts here in the hope to get feedback from you.
1. Introduction A multilinghual website is a website where the visitor can choose among several languages. Examples: - Sites with automatic language selection (using content negotiation): http://www.debian.org/ http://www.google.com/ These sites ask your browser about your preferred language. The same URL may return different content depending on your browser's settings. - Sites with manual language selection: http://www.taize.fr/ http://www.b-rail.be The visitor must choose their language when they enter through the top domain URL. A given URL will return the same content independently on the browser's settings. As far as I can see, content negotiation is done by the webserver, not by Sphinx. It is not possible on cheap hosts that offer limited configuration choices. 2. Organizing the source files I see two possible strategies to organize the source files: (a) a flat directory structure / Suffixes for each language: index.en.rst index.fr.rst events.en.rst events.fr.rst (b) a subdirectory for each language: en/index.rst fr/index.rst en/events.rst fr/events.rst I think I prefer (a), because (b) can be confusing when editing several languages at the same time. But this may be a matter of circumstances. 3. How to do it in Sphinx In Sphinx you can set a `language` variable in the conf.py. You need to make a subdirectory for each language. You can add a language selector to the sidebartoc by defining a custom template:: {% extends "!layout.html" %} {% block sidebartoc %} <p> <a href="../en/index.html">EN</a> <a href="../fr/index.html">FR</a> </p> {{ super() }} {% endblock %} (Note that this example is too simple, the links must refer to the translation of the current document, not a hard-coded index.html) 4. Conclusion Here's my suggestion for a small change in order to make maintenance of multilingual websites more easy: If the `language` variable doesn't hold a string but a callable, then call it before each rendering. With this change it would be possible to write in conf.py something like this:: def language_selector(docname): a=docname.split('.') return a[1] language=language_selector After a quick glance at the source code I guess that the following methods in builder.py need to be changed: - Builder.load_i18n() - StandaloneHTMLBuilder.init() - StandaloneHTMLBuilder.finish() I stop my thoughts at this point, hoping for your comments, critics, corrections... or patches. Thanks in advance, Luc --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to sphinx-dev@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en -~----------~----~----~----~------~----~------~--~---