Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install jsl10n

How to install jsl10n

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install jsl10n
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.1 Available View build log
Windows (64-bit)
1.1 Available View build log
Mac OS X (10.5+)
1.1 Available View build log
Linux (32-bit)
1.1 Available View build log
Linux (64-bit)
1.1 Available View build log
 
License
Apache 2.0
Dependencies
Lastest release
version 1.1 on Jan 5th, 2011

Javascript localization for Zope / Plone

jsl10n.js provides a function called 'translate' which takes at least 3 arguments: - the i18n domain; - an array of objects with the properties 'msgid' and 'default' set to the translation ID and default value, appropriately; - a callback function, which will be called with a single object argument with properties mapping translation IDs to translated strings once they have been retrieved. Further to these, there are 2 optional arguments: - a boolean value which when set to 'true' will cause the translations to be retrieved with each page load; - a boolean value which when set to 'true' causes debugging messages to be printed to the Javascript console. The function uses AJAX to call the view 'translate.js' which returns the JSON object given to the callback function. If the JSON call fails, the callback will still be triggered with the default values returned. Fallbacks should be implemented.

Example usage

required_translations = [ {'msgid':'my_message', 'default':'Hello world!'} ]; translate('domain', required_translations, function (translations) { alert(translations['my_message']); } );

Caveats
  • Any caching should use GET variables in the cache key for 'translate.js'.
  • These strings are not picked up by i18ndude, and therefore if they do not appear elsewhere in the codebase (in templates or Python code), they will not be added automatically to the POT files.
  • Since the POT files are managed automatically, if the strings are added to the POT files manually, they will be removed on next update. There are two possible solutions to this:

System Message: WARNING/2 (<string>, line 28)

Bullet list ends without a blank line; unexpected unindent.
  1. Define a new domain which is managed manuall;
  2. Create a dummy template file somewhere in the codebase which is never actually called, but contains all the msgids and defaults used exclusively in Javascript;
  3. Include the translations in sections of relevant templates in sections which are never rendered, for example:

<tal:comment tal:replace="nothing"> <span i18n:translate="my_message">Hello world!</span> </tal:comment>

Installation

Without buildout

Install this package in either your system path packages or in the lib/python directory of your Zope instance. You can do this using either easy_install or via the setup.py script. You'll also need to install plone.keyring in the same fashion.

After installing the package it needs to be registered in your Zope instance. This can be done by putting a jsl10n-configure.zcml file in the etc/package-includes directory with this content:

<include package="jsl10n" />

or, alternatively, you can add that line to the configure.zcml in a package or Product that is already registered.

With buildout

eggs = jsl10n zcml = jsl10n

Docutils System Messages

System Message: ERROR/3 (<string>, line 38); backlink

Unknown target name: "simplejson".

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:4

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.