[IPython-dev] Internationalisation and creating domain specific Help items

Ozan Çağlayan ozancag at gmail.com
Tue May 27 11:12:58 EDT 2014

On Thu, Dec 26, 2013 at 7:40 PM, Matthias BUSSONNIER
<bussonniermatthias at gmail.com> wrote:

> If I was in your position I would :
>  - Search/Ask who is interested would participate in such a translation project.
>  - Consider that only  5% of people who said will be interested in participating will participate
>  - depending on the result decide what is worth to do.
> In any case A document that describe in your language IPython and the significance of each term
> will be the easiest to update and take the less time. It will be useful even in a translated software to
> search for english documentation on the internet.
> If having a way to plug external translation is an minimal patch for IPython itself, we'll be
> happy to integrate it. As soon as you add something into IPython itself it will considerably
> slow you down as every change will have to go through the core team.
> If a deep change is required, go through an IPython Ehencement Proposal [3].


I'd be glad to revive this thread after months :)
I think I've come up with a minimally invasive patch using the jinja2
extension you have mentioned.

I think that it will be very confusing and fragile to set the language
using the system locale. It would be better to always default to
English unless the language switch is requested by the user.
I used the webapp_settings for this like below:

$ ipython notebook --NotebookApp.webapp_settings="{'language':'tr_TR'}"

And in the notebookapp.py, the following code installs the gettext() functions:

# Hack to rapidly include the extension
jenv_opt = jinja_env_options if jinja_env_options else
env = Environment(loader=FileSystemLoader(template_path),**jenv_opt)
# Get the Gettext translation object. If the language switch is not
requested, fallback to null, e.g. English.
gettext_translations = gettext.translation("ipynotebook",
          os.path.join(os.path.dirname(__file__), "locale"),
          [settings_overrides.get("language", "")], fallback=True)

I then used to decorate UI strings in the templates/ folder with {%
trans %} .. {% endtrans %} and extracted the gettext catalog using
pybabel. I can now change the UI language using the cmdline switch to

Some remarks:
- Extraction of translatable strings into catalogs should be done
periodically either before releases, or after each introduction of a
new translatable UI message,
- I used babel for extraction but don't know whether gettext is better.

Excited to hear about your comments!

Ozan Çağlayan
Research Assistant
Galatasaray University - Computer Engineering Dept.

More information about the IPython-dev mailing list