imports/vx/both/code/util.js
/**
     * Retrieve a message or template using a message ID string.
     *
     * @param {string} messageId Message ID string (e.g., "common.label_user_name")
     * @return {string} Message or string (or template with variables).
     */
Retrieve a message or template using a message ID string.
@param {string} messageId Message ID string
@return {string} Message or string (or template with variables).
Retrieve a message or template using a message ID string . @param { string } messageId Message ID string @return { string } Message or string ( or template with variables ) .
i18nRetrieve(messageId) {
        let messageParts = messageId.split(".")
        messageId = messageParts.pop()
        let messages = Meteor.i18nMessages
        while (messageParts.length) {
            messages = messages[messageParts.shift()]
            if (!_.isObject(messages)) {
                throw Error("missing namespace")
            }
        }
        let message = messages[messageId]
        if (!message) {
            throw Error("missing message")
        }
        if (_.isString(message)) {
            return message
        }
        let locale
        if (Meteor.isClient) {
            locale = Store.getState().currentLocale || "en_US"
        }
        else {
            locale = Meteor.locale || "en_US"
        }
        let _ref = locale.split("_")
        let language = _ref[0]
        let territory = _ref[1]
        message = message[language]
        if (_.isString(message)) {
            return message
        }
        if (_.isString(message !== null ? message[territory] : void 0)) {
            return message[territory]
        }
        if (_.isString(message !== null ? message.default : void 0)) {
            return message.default
        }
        throw Error("unknown message format")
    }
i18nRetrieve ( messageId ) { let messageParts = messageId . split ( "." ) messageId = messageParts . pop ( ) let messages = Meteor . i18nMessages while ( messageParts . length ) { messages = messages [ messageParts . shift ( ) ] if ( ! _ . isObject ( messages ) ) { throw Error ( "missing namespace" ) } } let message = messages [ messageId ] if ( ! message ) { throw Error ( "missing message" ) } if ( _ . isString ( message ) ) { return message } let locale if ( Meteor . isClient ) { locale = Store . getState ( ) . currentLocale || "en_US" } else { locale = Meteor . locale || "en_US" } let _ref = locale . split ( "_" ) let language = _ref [ 0 ] let territory = _ref [ 1 ] message = message [ language ] if ( _ . isString ( message ) ) { return message } if ( _ . isString ( message !== null ? message [ territory ] : void 0 ) ) { return message [ territory ] } if ( _ . isString ( message !== null ? message . default : void 0 ) ) { return message . default } throw Error ( "unknown message format" ) }
Retrieve a message or template using a message ID string.
Retrieve a message or template using a message ID string .