i18n-js 3.0.0.rc2 → 3.0.0.rc3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
 - data/Gemfile.lock +18 -18
 - data/README.md +4 -0
 - data/app/assets/javascripts/i18n.js +6 -52
 - data/lib/i18n/js/version.rb +1 -1
 - data/spec/js/numbers.spec.js +18 -0
 - metadata +4 -35
 
    
        data/.gitignore
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            pkg
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,35 +1,35 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                i18n-js (3.0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
                i18n-js (3.0.0.rc3)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  i18n
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            GEM
         
     | 
| 
       8 
8 
     | 
    
         
             
              remote: http://rubygems.org/
         
     | 
| 
       9 
9 
     | 
    
         
             
              specs:
         
     | 
| 
       10 
     | 
    
         
            -
                activesupport (3.2. 
     | 
| 
      
 10 
     | 
    
         
            +
                activesupport (3.2.8)
         
     | 
| 
       11 
11 
     | 
    
         
             
                  i18n (~> 0.6)
         
     | 
| 
       12 
12 
     | 
    
         
             
                  multi_json (~> 1.0)
         
     | 
| 
       13 
     | 
    
         
            -
                awesome_print (1.0 
     | 
| 
       14 
     | 
    
         
            -
                coderay (1.0. 
     | 
| 
      
 13 
     | 
    
         
            +
                awesome_print (1.1.0)
         
     | 
| 
      
 14 
     | 
    
         
            +
                coderay (1.0.8)
         
     | 
| 
       15 
15 
     | 
    
         
             
                diff-lcs (1.1.3)
         
     | 
| 
       16 
     | 
    
         
            -
                i18n (0.6. 
     | 
| 
       17 
     | 
    
         
            -
                method_source (0. 
     | 
| 
       18 
     | 
    
         
            -
                multi_json (1.3. 
     | 
| 
       19 
     | 
    
         
            -
                pry (0.9. 
     | 
| 
      
 16 
     | 
    
         
            +
                i18n (0.6.1)
         
     | 
| 
      
 17 
     | 
    
         
            +
                method_source (0.8.1)
         
     | 
| 
      
 18 
     | 
    
         
            +
                multi_json (1.3.6)
         
     | 
| 
      
 19 
     | 
    
         
            +
                pry (0.9.10)
         
     | 
| 
       20 
20 
     | 
    
         
             
                  coderay (~> 1.0.5)
         
     | 
| 
       21 
     | 
    
         
            -
                  method_source (~> 0. 
     | 
| 
       22 
     | 
    
         
            -
                  slop ( 
     | 
| 
      
 21 
     | 
    
         
            +
                  method_source (~> 0.8)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  slop (~> 3.3.1)
         
     | 
| 
       23 
23 
     | 
    
         
             
                rake (0.9.2.2)
         
     | 
| 
       24 
     | 
    
         
            -
                rspec (2. 
     | 
| 
       25 
     | 
    
         
            -
                  rspec-core (~> 2. 
     | 
| 
       26 
     | 
    
         
            -
                  rspec-expectations (~> 2. 
     | 
| 
       27 
     | 
    
         
            -
                  rspec-mocks (~> 2. 
     | 
| 
       28 
     | 
    
         
            -
                rspec-core (2. 
     | 
| 
       29 
     | 
    
         
            -
                rspec-expectations (2. 
     | 
| 
      
 24 
     | 
    
         
            +
                rspec (2.11.0)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  rspec-core (~> 2.11.0)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  rspec-expectations (~> 2.11.0)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  rspec-mocks (~> 2.11.0)
         
     | 
| 
      
 28 
     | 
    
         
            +
                rspec-core (2.11.1)
         
     | 
| 
      
 29 
     | 
    
         
            +
                rspec-expectations (2.11.3)
         
     | 
| 
       30 
30 
     | 
    
         
             
                  diff-lcs (~> 1.1.3)
         
     | 
| 
       31 
     | 
    
         
            -
                rspec-mocks (2. 
     | 
| 
       32 
     | 
    
         
            -
                slop ( 
     | 
| 
      
 31 
     | 
    
         
            +
                rspec-mocks (2.11.3)
         
     | 
| 
      
 32 
     | 
    
         
            +
                slop (3.3.3)
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
            PLATFORMS
         
     | 
| 
       35 
35 
     | 
    
         
             
              ruby
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -267,6 +267,10 @@ The only requirement is that you need to set the `translations` attribute like f 
     | 
|
| 
       267 
267 
     | 
    
         
             
                  message: "Uma mensagem especial para você"
         
     | 
| 
       268 
268 
     | 
    
         
             
                }
         
     | 
| 
       269 
269 
     | 
    
         | 
| 
      
 270 
     | 
    
         
            +
            ## Troubleshooting
         
     | 
| 
      
 271 
     | 
    
         
            +
             
     | 
| 
      
 272 
     | 
    
         
            +
            1. Want to support oldIE? Then you need to include something like [augment.js](http://augmentjs.com) or [es5-shim](https://github.com/kriskowal/es5-shim/).
         
     | 
| 
      
 273 
     | 
    
         
            +
             
     | 
| 
       270 
274 
     | 
    
         
             
            ## Maintainer
         
     | 
| 
       271 
275 
     | 
    
         | 
| 
       272 
276 
     | 
    
         
             
            - Nando Vieira - <http://nandovieira.com.br>
         
     | 
| 
         @@ -355,24 +355,16 @@ 
     | 
|
| 
       355 
355 
     | 
    
         | 
| 
       356 
356 
     | 
    
         
             
                formattedNumber = buffer.join(options.delimiter);
         
     | 
| 
       357 
357 
     | 
    
         | 
| 
       358 
     | 
    
         
            -
                if (options. 
     | 
| 
       359 
     | 
    
         
            -
                   
     | 
| 
      
 358 
     | 
    
         
            +
                if (options.strip_insignificant_zeros && precision) {
         
     | 
| 
      
 359 
     | 
    
         
            +
                  precision = precision.replace(/0+$/, "");
         
     | 
| 
       360 
360 
     | 
    
         
             
                }
         
     | 
| 
       361 
361 
     | 
    
         | 
| 
       362 
     | 
    
         
            -
                if ( 
     | 
| 
       363 
     | 
    
         
            -
                  formattedNumber  
     | 
| 
      
 362 
     | 
    
         
            +
                if (options.precision > 0 && precision) {
         
     | 
| 
      
 363 
     | 
    
         
            +
                  formattedNumber += options.separator + precision;
         
     | 
| 
       364 
364 
     | 
    
         
             
                }
         
     | 
| 
       365 
365 
     | 
    
         | 
| 
       366 
     | 
    
         
            -
                if ( 
     | 
| 
       367 
     | 
    
         
            -
                   
     | 
| 
       368 
     | 
    
         
            -
                      separator: new RegExp(options.separator.replace(/\./, "\\.") + "$")
         
     | 
| 
       369 
     | 
    
         
            -
                    , zeros: /0+$/
         
     | 
| 
       370 
     | 
    
         
            -
                  };
         
     | 
| 
       371 
     | 
    
         
            -
             
     | 
| 
       372 
     | 
    
         
            -
                  formattedNumber = formattedNumber
         
     | 
| 
       373 
     | 
    
         
            -
                    .replace(regex.zeros, "")
         
     | 
| 
       374 
     | 
    
         
            -
                    .replace(regex.separator, "")
         
     | 
| 
       375 
     | 
    
         
            -
                  ;
         
     | 
| 
      
 366 
     | 
    
         
            +
                if (negative) {
         
     | 
| 
      
 367 
     | 
    
         
            +
                  formattedNumber = "-" + formattedNumber;
         
     | 
| 
       376 
368 
     | 
    
         
             
                }
         
     | 
| 
       377 
369 
     | 
    
         | 
| 
       378 
370 
     | 
    
         
             
                return formattedNumber;
         
     | 
| 
         @@ -659,41 +651,3 @@ 
     | 
|
| 
       659 
651 
     | 
    
         
             
              I18n.l = I18n.localize;
         
     | 
| 
       660 
652 
     | 
    
         
             
              I18n.p = I18n.pluralize;
         
     | 
| 
       661 
653 
     | 
    
         
             
            })(typeof(exports) === "undefined" ? this["I18n"] = {} : exports);
         
     | 
| 
       662 
     | 
    
         
            -
             
     | 
| 
       663 
     | 
    
         
            -
            // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
         
     | 
| 
       664 
     | 
    
         
            -
            if (!Array.prototype.indexOf) {
         
     | 
| 
       665 
     | 
    
         
            -
              Array.prototype.indexOf = function(searchElement /*, fromIndex */) {
         
     | 
| 
       666 
     | 
    
         
            -
                "use strict";
         
     | 
| 
       667 
     | 
    
         
            -
             
     | 
| 
       668 
     | 
    
         
            -
                if (this === void 0 || this === null)
         
     | 
| 
       669 
     | 
    
         
            -
                  throw new TypeError();
         
     | 
| 
       670 
     | 
    
         
            -
             
     | 
| 
       671 
     | 
    
         
            -
                var t = Object(this);
         
     | 
| 
       672 
     | 
    
         
            -
                var len = t.length >>> 0;
         
     | 
| 
       673 
     | 
    
         
            -
                if (len === 0)
         
     | 
| 
       674 
     | 
    
         
            -
                  return -1;
         
     | 
| 
       675 
     | 
    
         
            -
             
     | 
| 
       676 
     | 
    
         
            -
                var n = 0;
         
     | 
| 
       677 
     | 
    
         
            -
                if (arguments.length > 0) {
         
     | 
| 
       678 
     | 
    
         
            -
                  n = Number(arguments[1]);
         
     | 
| 
       679 
     | 
    
         
            -
                  if (n !== n) // shortcut for verifying if it's NaN
         
     | 
| 
       680 
     | 
    
         
            -
                    n = 0;
         
     | 
| 
       681 
     | 
    
         
            -
                  else if (n !== 0 && n !== (Infinity) && n !== -(Infinity))
         
     | 
| 
       682 
     | 
    
         
            -
                    n = (n > 0 || -1) * Math.floor(Math.abs(n));
         
     | 
| 
       683 
     | 
    
         
            -
                }
         
     | 
| 
       684 
     | 
    
         
            -
             
     | 
| 
       685 
     | 
    
         
            -
                if (n >= len)
         
     | 
| 
       686 
     | 
    
         
            -
                  return -1;
         
     | 
| 
       687 
     | 
    
         
            -
             
     | 
| 
       688 
     | 
    
         
            -
                var k = n >= 0
         
     | 
| 
       689 
     | 
    
         
            -
                      ? n
         
     | 
| 
       690 
     | 
    
         
            -
                      : Math.max(len - Math.abs(n), 0);
         
     | 
| 
       691 
     | 
    
         
            -
             
     | 
| 
       692 
     | 
    
         
            -
                for (; k < len; k++) {
         
     | 
| 
       693 
     | 
    
         
            -
                  if (k in t && t[k] === searchElement)
         
     | 
| 
       694 
     | 
    
         
            -
                    return k;
         
     | 
| 
       695 
     | 
    
         
            -
                }
         
     | 
| 
       696 
     | 
    
         
            -
                return -1;
         
     | 
| 
       697 
     | 
    
         
            -
              };
         
     | 
| 
       698 
     | 
    
         
            -
            }
         
     | 
| 
       699 
     | 
    
         
            -
            ;
         
     | 
    
        data/lib/i18n/js/version.rb
    CHANGED
    
    
    
        data/spec/js/numbers.spec.js
    CHANGED
    
    | 
         @@ -121,4 +121,22 @@ describe("Numbers", function(){ 
     | 
|
| 
       121 
121 
     | 
    
         
             
              it("returns number as human size using custom options", function(){
         
     | 
| 
       122 
122 
     | 
    
         
             
                expect(I18n.toHumanSize(1024 * 1.6, {precision: 0})).toEqual("2KB");
         
     | 
| 
       123 
123 
     | 
    
         
             
              });
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
              it("formats numbers with strip insignificant zero", function() {
         
     | 
| 
      
 126 
     | 
    
         
            +
                options = {separator: ".", delimiter: ",", strip_insignificant_zeros: true};
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                options["precision"] = 2;
         
     | 
| 
      
 129 
     | 
    
         
            +
                expect(I18n.toNumber(1.0, options)).toEqual("1");
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                options["precision"] = 3;
         
     | 
| 
      
 132 
     | 
    
         
            +
                expect(I18n.toNumber(1.98, options)).toEqual("1.98");
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                options["precision"] = 4;
         
     | 
| 
      
 135 
     | 
    
         
            +
                expect(I18n.toNumber(1.987, options)).toEqual("1.987");
         
     | 
| 
      
 136 
     | 
    
         
            +
              });
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
              it("keeps significant zeros [issue#103]", function() {
         
     | 
| 
      
 139 
     | 
    
         
            +
                actual = I18n.toNumber(30, {strip_insignificant_zeros: true, precision: 0});
         
     | 
| 
      
 140 
     | 
    
         
            +
                expect(actual).toEqual("30");
         
     | 
| 
      
 141 
     | 
    
         
            +
              });
         
     | 
| 
       124 
142 
     | 
    
         
             
            });
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: i18n-js
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 3.0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.0.0.rc3
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 6
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2012- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-10-17 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: i18n
         
     | 
| 
         @@ -114,6 +114,7 @@ executables: [] 
     | 
|
| 
       114 
114 
     | 
    
         
             
            extensions: []
         
     | 
| 
       115 
115 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       116 
116 
     | 
    
         
             
            files:
         
     | 
| 
      
 117 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
       117 
118 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       118 
119 
     | 
    
         
             
            - Gemfile.lock
         
     | 
| 
       119 
120 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -167,9 +168,6 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       167 
168 
     | 
    
         
             
              - - ! '>='
         
     | 
| 
       168 
169 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       169 
170 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       170 
     | 
    
         
            -
                  segments:
         
     | 
| 
       171 
     | 
    
         
            -
                  - 0
         
     | 
| 
       172 
     | 
    
         
            -
                  hash: 4215591536209238864
         
     | 
| 
       173 
171 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       174 
172 
     | 
    
         
             
              none: false
         
     | 
| 
       175 
173 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -182,33 +180,4 @@ rubygems_version: 1.8.23 
     | 
|
| 
       182 
180 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       183 
181 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       184 
182 
     | 
    
         
             
            summary: It's a small library to provide the Rails I18n translations on the Javascript.
         
     | 
| 
       185 
     | 
    
         
            -
            test_files:
         
     | 
| 
       186 
     | 
    
         
            -
            - spec/fixtures/custom_path.yml
         
     | 
| 
       187 
     | 
    
         
            -
            - spec/fixtures/default.yml
         
     | 
| 
       188 
     | 
    
         
            -
            - spec/fixtures/js_file_per_locale.yml
         
     | 
| 
       189 
     | 
    
         
            -
            - spec/fixtures/locales.yml
         
     | 
| 
       190 
     | 
    
         
            -
            - spec/fixtures/multiple_conditions.yml
         
     | 
| 
       191 
     | 
    
         
            -
            - spec/fixtures/multiple_files.yml
         
     | 
| 
       192 
     | 
    
         
            -
            - spec/fixtures/no_config.yml
         
     | 
| 
       193 
     | 
    
         
            -
            - spec/fixtures/no_scope.yml
         
     | 
| 
       194 
     | 
    
         
            -
            - spec/fixtures/simple_scope.yml
         
     | 
| 
       195 
     | 
    
         
            -
            - spec/i18n_js_spec.rb
         
     | 
| 
       196 
     | 
    
         
            -
            - spec/js/currency.spec.js
         
     | 
| 
       197 
     | 
    
         
            -
            - spec/js/current_locale.spec.js
         
     | 
| 
       198 
     | 
    
         
            -
            - spec/js/dates.spec.js
         
     | 
| 
       199 
     | 
    
         
            -
            - spec/js/defaults.spec.js
         
     | 
| 
       200 
     | 
    
         
            -
            - spec/js/interpolation.spec.js
         
     | 
| 
       201 
     | 
    
         
            -
            - spec/js/jasmine/MIT.LICENSE
         
     | 
| 
       202 
     | 
    
         
            -
            - spec/js/jasmine/jasmine-html.js
         
     | 
| 
       203 
     | 
    
         
            -
            - spec/js/jasmine/jasmine.css
         
     | 
| 
       204 
     | 
    
         
            -
            - spec/js/jasmine/jasmine.js
         
     | 
| 
       205 
     | 
    
         
            -
            - spec/js/jasmine/jasmine_favicon.png
         
     | 
| 
       206 
     | 
    
         
            -
            - spec/js/localization.spec.js
         
     | 
| 
       207 
     | 
    
         
            -
            - spec/js/numbers.spec.js
         
     | 
| 
       208 
     | 
    
         
            -
            - spec/js/placeholder.spec.js
         
     | 
| 
       209 
     | 
    
         
            -
            - spec/js/pluralization.spec.js
         
     | 
| 
       210 
     | 
    
         
            -
            - spec/js/prepare_options.spec.js
         
     | 
| 
       211 
     | 
    
         
            -
            - spec/js/specs.html
         
     | 
| 
       212 
     | 
    
         
            -
            - spec/js/translate.spec.js
         
     | 
| 
       213 
     | 
    
         
            -
            - spec/js/translations.js
         
     | 
| 
       214 
     | 
    
         
            -
            - spec/spec_helper.rb
         
     | 
| 
      
 183 
     | 
    
         
            +
            test_files: []
         
     |