i18n-js 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
- require 'lib/i18n-js/version'
4
+ require File.dirname(__FILE__) + '/lib/i18n-js/version'
5
5
 
6
6
  desc 'Default: run unit tests.'
7
7
  task :default => :test
@@ -3,7 +3,7 @@ module SimplesIdeias
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 4
6
+ PATCH = 5
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
data/source/i18n.js CHANGED
@@ -4,6 +4,9 @@ var I18n = I18n || {};
4
4
  // Set default locale to english
5
5
  I18n.defaultLocale = "en";
6
6
 
7
+ // Set default separator
8
+ I18n.defaultSeparator = ".";
9
+
7
10
  // Set current locale to null
8
11
  I18n.locale = null;
9
12
 
@@ -20,14 +23,14 @@ I18n.lookup = function(scope, options) {
20
23
  }
21
24
 
22
25
  if (typeof(scope) == "object") {
23
- scope = scope.join(".");
26
+ scope = scope.join(this.defaultSeparator);
24
27
  }
25
28
 
26
29
  if (options.scope) {
27
- scope = options.scope.toString() + "." + scope;
30
+ scope = options.scope.toString() + this.defaultSeparator + scope;
28
31
  }
29
32
 
30
- scope = scope.split(".");
33
+ scope = scope.split(this.defaultSeparator);
31
34
 
32
35
  while (scope.length > 0) {
33
36
  var currentScope = scope.shift();
data/test/i18n-test.js CHANGED
@@ -1,6 +1,7 @@
1
1
  new Test.Unit.Runner({
2
2
  setup: function() {
3
3
  I18n.defaultLocale = "en";
4
+ I18n.defaultSeparator = ".";
4
5
  I18n.locale = null;
5
6
 
6
7
  I18n.translations = {
@@ -675,5 +676,12 @@ new Test.Unit.Runner({
675
676
  I18n.translations["en"]["new_syntax"] = "Hi %{name}!";
676
677
  actual = I18n.translate("new_syntax", {name: "John"});
677
678
  assertEqual("Hi John!", actual);
678
- }}
679
+ }},
680
+
681
+ // Return translation for custom scope separator
682
+ testReturnTranslationForCustomScopeSeparator: function() { with(this) {
683
+ I18n.defaultSeparator = "•";
684
+ actual = I18n.translate("greetings•stranger");
685
+ assertEqual("Hello stranger!", actual);
686
+ }},
679
687
  });
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-js
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 4
10
- version: 0.1.4
8
+ - 5
9
+ version: 0.1.5
11
10
  platform: ruby
12
11
  authors:
13
12
  - Nando Vieira
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-09-03 00:00:00 -03:00
17
+ date: 2010-09-15 00:00:00 -03:00
19
18
  default_executable:
20
19
  dependencies: []
21
20
 
@@ -64,7 +63,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
63
  requirements:
65
64
  - - ">="
66
65
  - !ruby/object:Gem::Version
67
- hash: 3
68
66
  segments:
69
67
  - 0
70
68
  version: "0"
@@ -73,7 +71,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
71
  requirements:
74
72
  - - ">="
75
73
  - !ruby/object:Gem::Version
76
- hash: 3
77
74
  segments:
78
75
  - 0
79
76
  version: "0"