Permalink
Browse files

v0.2.0

  • Loading branch information...
lchngr committed Mar 4, 2013
1 parent 5546f38 commit e9694786b5d8e54af7a15a71b27e58bcc6f99795
View
@@ -0,0 +1,5 @@
+v0.2.0
+======
+- added more tests
+- fixed missing addTranslation function bug
+- added currency and percent formatting
View
@@ -3,12 +3,7 @@ mondo
mondo is a i18n library for node and the browser. It features date- and number formatting, translations with string interpolation and pluralization.
-!!! this is alpha state code. use at your own risk. todo's prior version 1.0.0
-
-* complete tests
-* handlebar template cache
-* grunt task for precompiling handlebar templates
-* handlebar extensions for translating and formatting
+see [github issues](https://github.com/lchngr/mondo/issues?milestone=2&state=open) for open task prior version 1.0.0
Under the hood
--------------
@@ -1 +1 @@
-Mondo.addCultureInfo('de-CH', { messages: { foo: 'foo'}});
+Mondo.addTranslation('de-CH', { foo: 'foo'});
@@ -45,6 +45,14 @@ Mondo.time = Mondo.t = function(time) {
return this.format(time,'t');
};
+Mondo.currency = Mondo.c = function(amount) {
+ return this.format(amount,'c');
+};
+
+Mondo.percent = Mondo.p = function(number) {
+ return this.format(number,'p');
+};
+
Mondo.parseInt = function(value, radix, culture) {
return this.globalize.parseInt(value, radix, culture)
};
@@ -58,27 +66,13 @@ Mondo.parseDate = function(value, formats, culture) {
};
Mondo.localize = Mondo.l = function(key, options) {
- options = options || {};
var pluralizedKey = this.pluralize(key, options);
var message = this.translate(pluralizedKey);
return this.interpolate(message, options);
};
-Mondo.interpolate = function(source, options) {
- return this.handlebars.compile(source)(options);
-};
-
-Mondo.translate = function(key) {
- var message = this.globalize.culture().messages;
- var path = key.split('.');
- for(part in path) {
- message = message[path[part]];
- if(!message) return '';
- }
- return message;
-};
-
Mondo.pluralize = function(key, options) {
+ options = options || {};
var pluralize = options.pluralize;
if(pluralize || pluralize === 0) {
var size;
@@ -88,9 +82,6 @@ Mondo.pluralize = function(key, options) {
else if(pluralize.length) {
size = pluralize.length;
}
- else if(pluralize.size) {
- size = pluralize.size;
- }
else if(this._.isObject(pluralize)) {
size = this._.size(pluralize);
}
@@ -100,12 +91,30 @@ Mondo.pluralize = function(key, options) {
return key;
};
+Mondo.translate = function(key) {
+ var message = this.globalize.culture().messages;
+ var path = key.split('.');
+ for(var part in path) {
+ message = message[path[part]];
+ if(!message) return '';
+ }
+ return message;
+};
+
+Mondo.interpolate = function(source, options) {
+ return this.handlebars.compile(source)(options);
+};
+
Mondo.culture = function(selector) {
return this.globalize.culture(selector);
};
+Mondo.addTranslation = function(cultureName, translations) {
+ this.addCultureInfo(cultureName, { messages: translations });
+};
+
Mondo.addCultureInfo = function(cultureName, extendCultureName, info) {
this.globalize.addCultureInfo(cultureName, extendCultureName, info);
-}
+};
}(this));
@@ -5,8 +5,8 @@ require('globalize/lib/cultures/globalize.culture.de-CH');
require('globalize/lib/cultures/globalize.culture.fr-CH');
//Add translations
-Mondo.addCultureInfo('de-CH',{ messages: { foo: 'das isch z foo', bar: { one: 'bar', other: 'bars'}}});
-Mondo.addCultureInfo('fr-CH',{ messages: { foo: "c'est trop foo"}});
+Mondo.addTranslation('de-CH',{ foo: 'das isch z foo', bar: { one: 'bar', other: 'bars'}});
+Mondo.addTranslation('fr-CH',{ foo: "c'est trop foo"});
//Setting culture to be used
Mondo.culture('de-CH');
@@ -1,5 +1,5 @@
define(['mondo','culture-de-CH'],function(Mondo){
- Mondo.addCultureInfo('de-CH', { messages: { foo: 'foo'}});
+ Mondo.addTranslation('de-CH', { foo: 'foo'});
});
@@ -45,6 +45,14 @@ Mondo.time = Mondo.t = function(time) {
return this.format(time,'t');
};
+Mondo.currency = Mondo.c = function(amount) {
+ return this.format(amount,'c');
+};
+
+Mondo.percent = Mondo.p = function(number) {
+ return this.format(number,'p');
+};
+
Mondo.parseInt = function(value, radix, culture) {
return this.globalize.parseInt(value, radix, culture)
};
@@ -58,27 +66,13 @@ Mondo.parseDate = function(value, formats, culture) {
};
Mondo.localize = Mondo.l = function(key, options) {
- options = options || {};
var pluralizedKey = this.pluralize(key, options);
var message = this.translate(pluralizedKey);
return this.interpolate(message, options);
};
-Mondo.interpolate = function(source, options) {
- return this.handlebars.compile(source)(options);
-};
-
-Mondo.translate = function(key) {
- var message = this.globalize.culture().messages;
- var path = key.split('.');
- for(part in path) {
- message = message[path[part]];
- if(!message) return '';
- }
- return message;
-};
-
Mondo.pluralize = function(key, options) {
+ options = options || {};
var pluralize = options.pluralize;
if(pluralize || pluralize === 0) {
var size;
@@ -88,9 +82,6 @@ Mondo.pluralize = function(key, options) {
else if(pluralize.length) {
size = pluralize.length;
}
- else if(pluralize.size) {
- size = pluralize.size;
- }
else if(this._.isObject(pluralize)) {
size = this._.size(pluralize);
}
@@ -100,12 +91,30 @@ Mondo.pluralize = function(key, options) {
return key;
};
+Mondo.translate = function(key) {
+ var message = this.globalize.culture().messages;
+ var path = key.split('.');
+ for(var part in path) {
+ message = message[path[part]];
+ if(!message) return '';
+ }
+ return message;
+};
+
+Mondo.interpolate = function(source, options) {
+ return this.handlebars.compile(source)(options);
+};
+
Mondo.culture = function(selector) {
return this.globalize.culture(selector);
};
+Mondo.addTranslation = function(cultureName, translations) {
+ this.addCultureInfo(cultureName, { messages: translations });
+};
+
Mondo.addCultureInfo = function(cultureName, extendCultureName, info) {
this.globalize.addCultureInfo(cultureName, extendCultureName, info);
-}
+};
}(this));
View
@@ -1,6 +1,6 @@
{
"name": "mondo",
- "version": "0.0.1",
+ "version": "0.2.0",
"description": "i18n library for node and the browser",
"main": "./lib/mondo.js",
"scripts": {
@@ -31,6 +31,5 @@
],
"author": "Stefan Lüchinger",
"license": "BSD",
- "readmeFilename": "README.md",
- "gitHead": "9ba198d9d2464ca18ed5dc672852cd1ac77429a0"
+ "readmeFilename": "README.md"
}

0 comments on commit e969478

Please sign in to comment.