app/assets/javascripts/ultimate/improves/i18n-lite.js.coffee in ultimate-base-0.2.4 vs app/assets/javascripts/ultimate/improves/i18n-lite.js.coffee in ultimate-base-0.3.0.alpha
- old
+ new
@@ -1,14 +1,20 @@
-# TODO list
+# TODO list:
# * load all locales
+# * pluralize
-@I18n ||=
- locale: "en"
- translations: {}
+@I18n = $.extend true,
+ {
+ locale: "en"
+ translations: {}
- t: (path) ->
- path = path.split('.') if _.isString(path)
- scope = @translations
- for step in path
- scope = scope[step]
- return path.join('.') unless scope
- scope
+ translate: (path, options = {}) ->
+ path = path.split('.') if _.isString(path)
+ scope = @translations
+ for step in path
+ scope = scope[step]
+ return options['default'] ? path.join('.') unless scope?
+ scope
+
+ t: -> @translate arguments...
+
+ }, @I18n