Skip to content

Commit

Permalink
Probably necessary with multiple calls of Locale.use (which is bad an…
Browse files Browse the repository at this point in the history
…yway)
  • Loading branch information
Arian committed Mar 31, 2011
1 parent a695c62 commit 75a8b2d
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Source/Locale.API.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,23 @@ provides: Locale.API

var translateArguments = function(type, method, translate){

var oldMethod = type.prototype[method], methods = {};
var origin = type.prototype[method], methods = {};
if (origin.$origin) origin = origin.$origin;

methods[method] = function(){
var args = Array.map(arguments, function(value, i){
return (translate.arguments[i] && Object.keyOf(translate.arguments[i], value)) || value;
});
return oldMethod.apply(this, args);
};
return origin.apply(this, args);
}.extend({$origin: origin});

if (translate.method) methods[translate.method] = methods[method];
type.implement(methods);

};

var translateStatic = function(type, method, translate){

for (var old in translate){
type[translate[old]] = type[old];
}

var translateStatic = function(type, translate){
for (var old in translate) type[translate[old]] = type[old];
};

var alias = function(name, existing){
Expand All @@ -52,7 +49,7 @@ Locale.API = function(){

Object.each(methods, function(translate, method){

if (method == 'static') translateStatic(type, method, translate);
if (method == 'static') translateStatic(type, translate);
else if (typeOf(translate) == 'object') translateArguments(type, method, translate);
else aliasses[translate] = method;

Expand Down

0 comments on commit 75a8b2d

Please sign in to comment.