Issues

Issue #619 resolved

i18n not working on Windows

Hiroaki 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:

{{{

!python

    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 (3)

  1. Log in to comment