lib/routes/index.js
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 = vulpejs.i18n.__n({
          singular: singular,
          plural: plural,
          count: request.query.count,
          locale: locale,
        });
        // Retrieve the translation object from the catalog and return it.
        var catalog = vulpejs.i18n.getCatalog(locale);
        result = singular.split(configuration.objectNotation).reduce(function (object, index) {
          return object[index];
        }, catalog);
      } else {
        result = vulpejs.i18n.__({
          phrase: phrase,
          locale: locale,
        });
      }
      response.send(result);
    }
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 = vulpejs.i18n.__n({
          singular: singular,
          plural: plural,
          count: request.query.count,
          locale: locale,
        });
        // Retrieve the translation object from the catalog and return it.
        var catalog = vulpejs.i18n.getCatalog(locale);
        result = singular.split(configuration.objectNotation).reduce(function (object, index) {
          return object[index];
        }, catalog);
      } else {
        result = vulpejs.i18n.__({
          phrase: phrase,
          locale: locale,
        });
      }
      response.send(result);
    }
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 = vulpejs . i18n . __n ( { singular : singular , plural : plural , count : request . query . count , locale : locale , } ) ; // Retrieve the translation object from the catalog and return it. var catalog = vulpejs . i18n . getCatalog ( locale ) ; result = singular . split ( configuration . objectNotation ) . reduce ( function ( object , index ) { return object [ index ] ; } , catalog ) ; } else { result = vulpejs . i18n . __ ( { phrase : phrase , locale : locale , } ) ; } response . send ( result ) ; }
Translate a given string and provide the result.
@param request
@param response
Translate a given string and provide the result .