Skip to content
jQuery plugin acting as a wrapper for jquery.tr in CouchApps.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
LICENSE
README.md
jquery.couch.tr.js
jquery.couch.tr.min.js

README.md

jquery.couch.tr

jquery.couch.tr is a jQuery plugin acting as a wrapper for jquery.tr in CouchApps.

See the related jquery.tr project.

Usage

Add a directory _languages inside your evently/widget directory. This new directory shall contains the translation files.

Translation files may be simple JSON for easy cases. They must contain an object, with the original sentence or string id as key, and the translated sentence as value.

If the translated texts need to be generated according to given parameters, then the file should be a JS function, which returns an object in the same format as previously. It may be easier to writer helper functions to handle language specific grammar rules:

en.js:

function() {
	function plural(singular, plural) {
		return function(n) {
			(n == 1) ? singular : plural;
		}
	}
	
	return {
		'You have &1 mail(s).' : plural('You have &1 mail.', 'You have &1 mails.')
	}
}

Example

The example given is the default CouchApp given by couchapp generate, modified to use translations.

It also uses jQote2 as template engine, which is available with my fork of couchapp (not maintained).

Misc

Licensed under a MIT license, see the LICENSE file.

Official site: https://github.com/Bloutiouf/jquery.couch.tr

You can’t perform that action at this time.