var Messages = require('./messages');

require('./lang/en');

var container = {

  messages: {},

  /**
   * Set messages for language
   *
   * @param {string} lang
   * @param {object} rawMessages
   * @return {void}
   */
  _set: function(lang, rawMessages) {
    this.messages[lang] = rawMessages;
  },

  /**
   * Set message for given language's rule.
   *
   * @param {string} lang
   * @param {string} attribute
   * @param {string|object} message
   * @return {void}
   */
  _setRuleMessage: function(lang, attribute, message) {
    this._load(lang);
    if (message === undefined) {
      message = this.messages[lang].def;
    }

    this.messages[lang][attribute] = message;
  },

  /**
   * Load messages (if not already loaded)
   *
   * @param  {string} lang
   * @return {void}
   */
  _load: function(lang) {
      var langs = {
        en : './lang/en',
        de : './lang/de'
        }
    if (!this.messages[lang]) {
        var load = langs[lang];
      var rawMessages = require(load);
      this._set(lang, rawMessages);
    }
  },

  /**
   * Get raw messages for language
   *
   * @param  {string} lang
   * @return {object}
   */
  _get: function(lang) {
    this._load(lang);
    return this.messages[lang];
  },

  /**
   * Make messages for given language
   *
   * @param  {string} lang
   * @return {Messages}
   */
  _make: function(lang) {
    this._load(lang);
    return new Messages(lang, this.messages[lang]);
  }

};

module.exports = container;

@@ -827,148 +827,109 @@
     
-  var langs = %7B%0A        en : './lang/en',%0A        de : './lang/de'%0A        %7D%0A    if (!this.messages%5Blang%5D) %7B%0A        var load = langs%5Blang%5D;
+if (!this.messages%5Blang%5D) %7B%0A        // TODO: make dynamic require possible to support other languages
 %0A   
@@ -957,20 +957,27 @@
 require(
-load
+'./lang/en'
 );%0A     

make static require to support react native packager