utils/i18n.js
function translate(val, scope, status) {
        var app = (scope && scope.appName) || context.get('app') || '';
        var lang = (scope && scope.lang) || context.get('lang') || 'en';
        var translated;

        // if just one character or is a number, don't do translation
        if (!val || val.length < 2 || !isNaN(val)) {
            return val;
        }

        // translations could be either nested (on the server) or at the root (on the client)
        translated = (translations[app] && translations[app][lang] && translations[app][lang][val]) ||
            (_.isString(translations[val]) && translations[val]);

        // if no transation AND caller passed in status object AND lang is not default (i.e. not english),
        // set the status object values which the caller can use to record some info
        // note: this is kind of hacky, but we want the caller (i.e. jng.directives.js) to handle
        // it because jng.directives has more info about the translation than we do at this level
        if (!translated && config.i18nDebug && status && lang !== config.lang.default) {
            status.app = app;
            status.lang = lang;
            status.missing = true;
        }

        // attempt to interpolate and return the resulting value (val if no translation found)
        return interpolate(translated || val, scope);
    }
function translate(val, scope, status) {
        var app = (scope && scope.appName) || context.get('app') || '';
        var lang = (scope && scope.lang) || context.get('lang') || 'en';
        var translated;

        // if just one character or is a number, don't do translation
        if (!val || val.length < 2 || !isNaN(val)) {
            return val;
        }

        // translations could be either nested (on the server) or at the root (on the client)
        translated = (translations[app] && translations[app][lang] && translations[app][lang][val]) ||
            (_.isString(translations[val]) && translations[val]);

        // if no transation AND caller passed in status object AND lang is not default (i.e. not english),
        // set the status object values which the caller can use to record some info
        // note: this is kind of hacky, but we want the caller (i.e. jng.directives.js) to handle
        // it because jng.directives has more info about the translation than we do at this level
        if (!translated && config.i18nDebug && status && lang !== config.lang.default) {
            status.app = app;
            status.lang = lang;
            status.missing = true;
        }

        // attempt to interpolate and return the resulting value (val if no translation found)
        return interpolate(translated || val, scope);
    }
function translate ( val , scope , status ) { var app = ( scope && scope . appName ) || context . get ( 'app' ) || '' ; var lang = ( scope && scope . lang ) || context . get ( 'lang' ) || 'en' ; var translated ; // if just one character or is a number, don't do translation if ( ! val || val . length < 2 || ! isNaN ( val ) ) { return val ; } // translations could be either nested (on the server) or at the root (on the client) translated = ( translations [ app ] && translations [ app ] [ lang ] && translations [ app ] [ lang ] [ val ] ) || ( _ . isString ( translations [ val ] ) && translations [ val ] ) ; // if no transation AND caller passed in status object AND lang is not default (i.e. not english), // set the status object values which the caller can use to record some info // note: this is kind of hacky, but we want the caller (i.e. jng.directives.js) to handle // it because jng.directives has more info about the translation than we do at this level if ( ! translated && config . i18nDebug && status && lang !== config . lang . default ) { status . app = app ; status . lang = lang ; status . missing = true ; } // attempt to interpolate and return the resulting value (val if no translation found) return interpolate ( translated || val , scope ) ; }
Translate given text into the target language. If not in the target language,
look in english, and then finally just return back the value itself

@param val
@param scope
@param status
@returns {string}
Translate given text into the target language . If not in the target language look in english and then finally just return back the value itself