This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

doublespeak

Doublespeak lets you extract translateable messages in Javascript into separate PO files and then lets you compile them to JSON files that can for example be used with gettext.js

Motivation

Many modern Python web applications also include a significant amount of translatable strings in Javascript.

Because this Javascript code runs in the browser, instead of on the server where the Python code runs, it’s necessary to have its translateable messages in separate gettext PO files, from which you can then generate JSON/Javascript translation files to load in your browser.

Unfortunately, Babel, which provides distutils commands to create messages catalogs, and extract and compile messages, doesn’t allow you to create different catalogs for the same language in one package.

Doublespeak lets you do this, by providing new Babel/distutils commands that you can use to extract translateable messages from Javascript, and keep them separatele from the rest of your application’s translations.

New distutils commands:

The new distutils commands made available by doublespeak, are:

  • init_js_catalog - Initialize a new gettext catalog, specifically for JS messages.
  • extract_js_messages - Extract messages from JS and put them in the catalog.
  • update_js_catalog - Update an existing catalog with messages from newer JS code.
  • compile_js_catalog - Create the compiled .mo and JSON files from the .po files

Users of Babel, will notice that these commands are very similar to the ones provided by Babel:

  • init_catalog
  • extract_messages
  • update_catalog
  • compile_catalog

Some of the doublespeak commands are simply wrappers around Babel commands. The benefit they provide is that you can configure them independently from the Babel commands, for example in your setup.cfg file.

Configuration

Here’s an example setup.cfg file, which demonstrates how you can configure the standard Babel commands and the new Doublespeak commands:

[compile_catalog]
# Change to a relevant domain
domain = mypackage
directory = src/mypackage/i18n/locales

[compile_js_catalog]
# Note that the Javascript files have a different domain. You'll need to use
# this domain in your Javascript code, instead of using the domain above,
# declared for the Python code.
domain = mypackagejs
# Contrary to compile_catalog, this commands takes both input and output
directories, so that you can write the JSON translation files to a separate
directory, where you might have the rest of your Javascript code.
input_dir = src/mypackage/i18n/locales
output_dir = src/mypackage/browser/resources/js/i18n

[extract_messages]
# Change to your organisation
copyright_holder = Acme Inc.
output_file = src/mypackage/i18n/locales/en/LC_MESSAGES/mypackage.po
charset = UTF-8
add-comments = i18n

[extract_js_messages]
keywords = __
no-default-keywords = True
copyright_holder = Acme Inc.
output_file = src/mypackage/i18n/locales/en/LC_MESSAGES/mypackagejs.po
charset = UTF-8
add-comments = i18n

[init_catalog]
domain = mypackage
input_file = src/mypackage/i18n/locales/en/LC_MESSAGES/mypackage.po
output_dir = src/mypackage/i18n/locales

[init_js_catalog]
domain = mypackagejs
input_file = src/mypackage/i18n/locales/en/LC_MESSAGES/mypackagejs.po
output_dir = src/mypackage/i18n/locales

[update_catalog]
domain = mypackage
input_file = src/mypackage/i18n/locales/en/LC_MESSAGES/mypackage.po
output_dir = src/mypackage/i18n/locales

[update_js_catalog]
domain = mypackagejs
input_file = src/mypackage/i18n/locales/en/LC_MESSAGES/mypackagejs.po
output_dir = src/mypackage/i18n/locales

Changes

0.3 (2016-03-07)

  • The output file javascript is jshint happy now.

0.2 (2016-03-04)

  • Simplify the generated Javascript translations files.
  • Add the “output-prefix” option to prefix the filenames of generated language .js files, defaults to ”.
  • Add ‘statistics’ and ‘use-fuzzy’ to be on par with Babel’s compile_catalog.
  • Build js files based on .po files instead of .mo files.

0.1 (2016-02-26)

  • Initial release.
Release History

Release History

0.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
doublespeak-0.3.tar.gz (6.4 kB) Copy SHA256 Checksum SHA256 Source Mar 7, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting