No project description provided
Project description
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:
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>
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/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
Copyright
=========
Copyright 2010 Isotoma Limited
Licensed 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 at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.
========================================
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:
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>
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/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
Copyright
=========
Copyright 2010 Isotoma Limited
Licensed 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 at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsl10n-1.1.tar.gz
(12.1 kB
view details)
Built Distributions
jsl10n-1.1-py2.6.egg
(11.6 kB
view details)
jsl10n-1.1-py2.5.egg
(11.6 kB
view details)
jsl10n-1.1-py2.4.egg
(11.6 kB
view details)
File details
Details for the file jsl10n-1.1.tar.gz
.
File metadata
- Download URL: jsl10n-1.1.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6001bba392dc0aa5351ea72e096e86656e204faca695861172a185be3459d85f |
|
MD5 | 14a7d81f5e39bed2e21707a8e585ccb4 |
|
BLAKE2b-256 | 0c5cdaa38fb0be926af273d352c6b9f2ee20acddf69e689fb62260aa01a40c71 |
File details
Details for the file jsl10n-1.1-py2.6.egg
.
File metadata
- Download URL: jsl10n-1.1-py2.6.egg
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d074a6ce1476d733aec222445d94c6e40c52a014db75d59f4fef9640626296b8 |
|
MD5 | fae8cb8d2de2b9d09941c20780a06a50 |
|
BLAKE2b-256 | 2ba88e6a24eeae3348dbbd7b60e1061221d8ef0d6d0e369e7cd199f23d9f8ac4 |
File details
Details for the file jsl10n-1.1-py2.5.egg
.
File metadata
- Download URL: jsl10n-1.1-py2.5.egg
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 232c5fda832381480fceba8b9a346931a34c86fa5b197902a5978101315bce8b |
|
MD5 | 7fc60777f858ae09e07da3d84a1a2757 |
|
BLAKE2b-256 | b17c37b36707255ecf10b4a3ccdd889b3a986ec4b9840100bc3194e4113c5272 |
File details
Details for the file jsl10n-1.1-py2.4.egg
.
File metadata
- Download URL: jsl10n-1.1-py2.4.egg
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad82b9663bbc0e864ecb7234fad35119b31c1dd61c348574dff46af5403817b8 |
|
MD5 | 0437165c98ef77a16dd9caae7ee69102 |
|
BLAKE2b-256 | f7432c31d6af752ba1418417469ea26fae7bddba0124a4bb9d5f59f133418086 |