drupal_add_js and variables into anonymous functions, objects undefined?
As of Drupal 6 javascript is put inside function that we assign as a property of Drupal.behaviors. Example,

Drupal.behaviors.myModuleBehavior = function (context) {
  //Do some fancy stuff
};


Drupal 7.x:

Drupal.behaviors.myModuleBehavior = {
  attach: function (context, settings) {
    $('input.myCustomBehavior', context).once('myCustomBehavior', function () {
    // Apply the myCustomBehaviour effect to the elements only once.
    });
  }
};


So your code should be 

(function($) {
  Drupal.behaviors.myModuleBehavior = {
    attach: function (context, settings) {
      var my_var = Drupal.settings.mymodule.lang;
      console.log(my_var); 
      console.log(language); 
    }
  };
})(jQuery);