Exemplo n.º 1
0
	translate : function( request, response ) {
		var locale = request.params.locale;
		var phrase = request.params.phrase;

		var result;
		if( request.query.plural ) {
			var singular = phrase;
			var plural = request.query.plural;
			// Make sure the information is added to the catalog if it doesn't exist yet.
			var translated = i18n.__n( {
				singular : singular,
				plural   : plural,
				count    : request.query.count,
				locale   : locale
			} );
			// Retrieve the translation object from the catalog and return it.
			var catalog = i18n.getCatalog( locale );
			result = singular.split( configuration.objectNotation ).reduce( function( object, index ) {
				return object[ index ];
			}, catalog );

		} else {
			result = i18n.__( { phrase : phrase, locale : locale } );
		}
		response.send( result );
	}
Exemplo n.º 2
0
MyI18n.prototype.n__n = function(opt)
{
	if( !this.nativeLocale ){
		return this.__n(opt);
	}
	else {
		opt.locale = this.nativeLocale;
		return i18n.__n(opt);
	}
};
Exemplo n.º 3
0
  translate : function( request, response ) {
    var locale = request.params.locale;
    var phrase = request.params.phrase;

    var result;
    if( request.query.plural ) {
      var singular = phrase;
      var plural = request.query.plural;
      // Make sure the information is added to the catalog if it doesn't exist yet.
      i18n.__n( {singular : singular, plural : plural, locale : locale} );
      // Retrieve the translation object from the catalog and return it.
      var catalog = i18n.getCatalog(locale);
      result = catalog[singular];

    } else {
      result = i18n.__( {phrase : phrase, locale : locale} );
    }
    response.send( result );
  }
Exemplo n.º 4
0
MyI18n.prototype.__n = function(opt)
{
	opt.locale = this.selectedLocale;
	return i18n.__n(opt);
};