Browse files

Updated README with examples of how to use node-localize in the brows…

…er, using the new Localize.source property, and therefore bumping the revision again.
  • Loading branch information...
David Ellis
David Ellis committed Feb 10, 2012
1 parent 14bdc35 commit 162166164227fcf8c602ccdbbf72c11a724dd9ba
Showing with 26 additions and 1 deletion.
  1. +25 −0
  2. +1 −1 package.json
@@ -110,6 +110,12 @@ myLocalize.loadTranslations(translationsObjOrStr);
// object in memory (overwriting duplicate keys).
+// translationsArrOrUndef: an array of untranslated text whose translations you want
+// to acquire, or leave it undefined for the entire internal translations object
// Wipes out the translations object entirely (if a clean reload is desired)
@@ -138,6 +144,11 @@ myLocalize.loadDateFormats(dateFormatObj);
// loadTranslations.
+// Returns the internal date formats object.
// Resets the date formats object to just the 'en' locale.
@@ -236,6 +247,20 @@ Your controllers shouldn't really even be aware of any localization issues; the
I'm using [jQuery Templates for Express]( here, but it should be easy to translate to whatever templating language you prefer.
+### Easy exporting of *node-localize* library to client without copying library into own source
+Since node-localize can also run inside of the browser, and so can jQuery Templates, it can be quite useful to be able to export the library to the client. But rather than manually copying the library code into your website (and keeping track of updates/bugfixes manually), you can get the source code of node-localize directly from the library and add an Express route for it:
+app.get('/js/localize.js', function(req, res) {
+ res.send(Localize.source);
+Where ``Localize`` is equivalent to ``require('localize')``, not an instantiated localize object.
+If you're using node-localize on the client in this fashion, it would be wise to add ``getTranslations`` and ``getDateFormats`` to the ``app.helpers`` object, so views can specify which translations and date formatting they need the client to have to function properly.
## Planned Features
* Browser compatibility (use same functions for client-side jQuery Templates, for instance)
@@ -9,7 +9,7 @@
"Clint Andrew Hall",
"Jerry Jalava"
- "version": "0.4.2",
+ "version": "0.4.3",
"main": "./lib/localize",
"dependencies": {},
"devDependencies": {

0 comments on commit 1621661

Please sign in to comment.