i18n not working on Windows

Hiroaki Hasegawa avatarHiroaki Hasegawa created an issue

Though the internationalization feature for user documents which will be introduced in Sphinx 1.1 is really amazing, there seems to be a little bug -- it doesn't work on Windows. On Linux platforms Sphinx 1.1pre (tip) correctly replaces original messages with translated ones, but on Windows it does no replacement.

I found that this is because an incorrect catalog name is passed to `sphinx.locale.init()` (in `sphinx/locale/init.py`); on Windows, it is something like `\directory\filename`.

I also found that `sphinx.locale.init()` is called from `sphinx.environment.Locale.apply()` (in `sphinx/environment.py`) as follows:

        docname = posixpath.splitext(source[len(env.srcdir):].lstrip('/'))[0]
        section = docname.split(SEP, 1)[0]

That is why the value of `catalog` argument of init (init_locale) remains intact on Windows machines. Of course gettext cannot find the `.mo` file and no translation takes place.

I think it is desirable to use `os.sep` rather than '/' or `SEP`, and `os.path` than `posixpath`. I created and attached a patch which makes this fix: Sphinx_rev3237.patch. I confirmed the patch both works on Windows 7 and Ubuntu Linux 10.10.

Comments (2)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.