Package: jsl10n
Javascript localization for Zope / Plone========================================jsl10n.js provides a function called 'translate' which takes at least 3arguments:- the i18n domain;- an array of objects with the properties 'msgid' and 'default' set to thetranslation ID and default value, appropriately;- a callback function, which will be called with a single object argument withproperties mapping translation IDs to translated strings once they have beenretrieved. Further to these, there are 2 optional arguments:- a boolean value which when set to 'true' will cause the translations to beretrieved with each page load;- a boolean value which when set to 'true' causes debugging messages to beprinted to the Javascript console.The function uses AJAX to call the view 'translate.js' which returns the JSONobject given to the callback function. If the JSON call fails, the callback willstill be triggered with the default values returned. Fallbacks should beimplemented.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 notappear elsewhere in the codebase (in templates or Python code), they will not beadded automatically to the POT files.- Since the POT files are managed automatically, if the strings are added tothe POT files manually, they will be removed on next update. There are twopossible solutions to this:1) Define a new domain which is managed manuall;2) Create a dummy template file somewhere in the codebase which is neveractually called, but contains all the msgids and defaults used exclusively inJavascript;3) Include the translations in sections of relevant templates in sectionswhich are never rendered, for example:<tal:comment tal:replace="nothing"><span i18n:translate="my_message">Hello world!</span></tal:comment>Dependencies------------simplejson_.. _simplejson: http://pypi.python.org/pypi/simplejson/Installation============Without buildout----------------Install this package in either your system path packages or in the lib/pythondirectory of your Zope instance. You can do this using either easy_install orvia the setup.py script. You'll also need to install plone.keyring in the samefashion.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 theetc/package-includes directory with this content::<include package="jsl10n" />or, alternatively, you can add that line to the configure.zcml in a package orProduct that is already registered.With buildout-------------eggs = jsl10nzcml = jsl10nCopyright=========Copyright 2010 Isotoma LimitedLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.