l10n 1.6.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/README.md +50 -18
- data/lib/install/install.rb +2 -0
- data/lib/install/l10n.js +45 -0
- data/lib/l10n/core_extensions/date_time_ext.rb +2 -2
- data/lib/l10n/core_extensions/numeric_ext.rb +6 -10
- data/lib/l10n/core_extensions/object_ext.rb +1 -1
- data/lib/l10n/forms.rb +1 -0
- data/lib/l10n/i18n_extensions.rb +1 -1
- data/lib/l10n/railtie.rb +11 -0
- data/lib/l10n/version.rb +1 -1
- data/lib/l10n.rb +9 -6
- data/lib/tasks/l10n.rake +8 -0
- metadata +25 -84
- data/CHANGELOG +0 -9
- data/app/assets/javascripts/i18n.js +0 -42
- data/lib/l10n/core_extensions/big_decimal_ext.rb +0 -17
- data/lib/l10n/core_extensions.rb +0 -6
- data/lib/l10n/engine.rb +0 -7
- data/lib/l10n/javascript_helper.rb +0 -17
- data/lib/locales/de.yml +0 -8
- data/lib/locales/en.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 983a6cc561859d662fc97347df35643e42444b6c996b1ff224a327a0fe5dfe77
|
4
|
+
data.tar.gz: f4baa0c9c30895603cec6ec75c93236d1a9b8668e7d3f0912b2ae5303093cabe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9856cc22286c2cf3ec0731c46e047024f9963efdfd957126d6a0f659c0c435d8625b22b1aa2e2e70722b869d7663845c8879568fccab9e567450d1bdd73dc7df
|
7
|
+
data.tar.gz: 21bbb3ac8f822c9c70e2ce90fa74917bc621e86ea77dfd4ec87fcadbaf8d7cc39d0af425618bf2cae46b1736878b7680c1aa0f171fbea184abd982c3872260bd
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
## 2.0.0 - Unreleased
|
2
|
+
|
3
|
+
- Support Rails 7
|
4
|
+
- use `to_lfs` instead of `to_formatted_s` which has been reclaimed by Rails
|
5
|
+
- JS: move implementation to ES module, drop JavaScriptHelper
|
6
|
+
- Inflections: drop ordinalization, provided by Rails now
|
7
|
+
|
8
|
+
## 1.4.0 - 2018-06-21
|
9
|
+
|
10
|
+
- Removing jQuery dependency from i18n javascript
|
11
|
+
|
12
|
+
## 1.1.0 - 2014-12-09
|
13
|
+
|
14
|
+
- Adding Time#l
|
15
|
+
- Adding I18n support for JavaScript
|
16
|
+
- Updating README
|
data/{MIT-LICENSE → LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/l10n.png)](http://badge.fury.io/rb/l10n)
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/l10n.png)](http://badge.fury.io/rb/l10n)
|
2
|
+
[![build](https://github.com/mtgrosser/l10n/actions/workflows/build.yml/badge.svg)](https://github.com/mtgrosser/l10n/actions/workflows/build.yml)
|
3
|
+
|
2
4
|
# L10n - I18n that roarrrs
|
3
5
|
|
4
|
-
L10n provides some useful extensions for Rails I18n, including column translations,
|
6
|
+
L10n provides some useful extensions for Rails I18n, including column translations,
|
7
|
+
localization of numeric form fields and JavaScript translation support.
|
5
8
|
|
6
9
|
## Installation
|
7
10
|
|
@@ -98,18 +101,21 @@ I18n.locale = :de
|
|
98
101
|
|
99
102
|
#### Formatting of numbers
|
100
103
|
|
101
|
-
Calling `
|
104
|
+
Calling `to_lfs` on `Numeric`s returns the number as a localized formatted string.
|
105
|
+
The format is defined by the current locale and respects the decimal delimiters
|
106
|
+
and separators defined in your `<locale>.yml`.
|
102
107
|
|
103
108
|
```ruby
|
104
|
-
I18n.as('de') { 1234.5.
|
105
|
-
I18n.as('en') { 1234.5.
|
109
|
+
I18n.as('de') { 1234.5.to_lfs } => "1.234,50"
|
110
|
+
I18n.as('en') { 1234.5.to_lfs } => "1,234.50"
|
106
111
|
```
|
107
112
|
|
108
113
|
This also works with `BigDecimal`s.
|
109
114
|
|
110
115
|
#### Localization of decimal separator and delimiter for numbers
|
111
116
|
|
112
|
-
Localization converts decimal separators and delimiters between locales without
|
117
|
+
Localization converts decimal separators and delimiters between locales without
|
118
|
+
re-formatting strings. `to_localized_s` can be called on any object.
|
113
119
|
|
114
120
|
```ruby
|
115
121
|
I18n.as('de') { 1234.5.to_localized_s } => "1.234,5"
|
@@ -125,7 +131,9 @@ I18n.as(:en) { Numeric.localize('1,234.50') } => "1,234.50"
|
|
125
131
|
|
126
132
|
### Automatic localization of numeric values in Rails forms and models
|
127
133
|
|
128
|
-
The `amount_field` form helper automatically formats numbers in the current locale.
|
134
|
+
The `amount_field` form helper automatically formats numbers in the current locale.
|
135
|
+
Numeric columns automatically convert the localized strings into numbers,
|
136
|
+
respecting decimal delimiters and separators.
|
129
137
|
|
130
138
|
```ruby
|
131
139
|
# in your template
|
@@ -145,7 +153,8 @@ I18n.locale = :en
|
|
145
153
|
|
146
154
|
### Accept-Language header parsing in ActionDispatch::Request
|
147
155
|
|
148
|
-
The `Accept-Language` HTTP header will be parsed, and locales will be returned ordered
|
156
|
+
The `Accept-Language` HTTP header will be parsed, and locales will be returned ordered
|
157
|
+
by user preference. This comes in handy when setting the current locale in a `before_action`.
|
149
158
|
|
150
159
|
```ruby
|
151
160
|
# in your controller
|
@@ -154,14 +163,15 @@ request.accept_locales => ["en-US", "en", "en-GB"]
|
|
154
163
|
|
155
164
|
### Javascript I18n, interpolation and pluralization
|
156
165
|
|
157
|
-
|
166
|
+
Due to the many different options of integrating JavaScript, the `l10n.js` file
|
167
|
+
is no longer provided as a standard Rails asset. Instead, it can be installed
|
168
|
+
manually using
|
158
169
|
|
159
|
-
```
|
160
|
-
|
161
|
-
//= require i18n
|
170
|
+
```sh
|
171
|
+
rake l10n:install:js
|
162
172
|
```
|
163
173
|
|
164
|
-
|
174
|
+
Place your JavaScript translations below the `javascript` key:
|
165
175
|
|
166
176
|
```yaml
|
167
177
|
# en.yml
|
@@ -174,14 +184,36 @@ en:
|
|
174
184
|
other: '{count} apples'
|
175
185
|
```
|
176
186
|
|
187
|
+
Import the module:
|
188
|
+
|
189
|
+
```javascript
|
190
|
+
import I18n from 'l10n';
|
191
|
+
```
|
192
|
+
|
193
|
+
Render the translations either as JSON via an endpoint, or include them in a
|
194
|
+
`script` tag:
|
195
|
+
|
177
196
|
```ruby
|
178
|
-
|
179
|
-
<%= i18n_script_tag %>
|
197
|
+
I18n.t(:javascript).to_json
|
180
198
|
```
|
181
199
|
|
200
|
+
Depending on the way the module is integrated, the translations can either be
|
201
|
+
set on the `I18n` object:
|
202
|
+
|
203
|
+
```javascript
|
204
|
+
import I18n from 'l10n';
|
205
|
+
window.I18n = I18n;
|
206
|
+
I18n.translations = { "hello": "Hello {name}!", "apple": { "one": "{count} apple", "other": "{count} apples" } };
|
207
|
+
|
208
|
+
I18n.t("hello", { name: "JS" }) => "Hello JS!"
|
209
|
+
I18n.t("apple", { count: 5 }) => "5 apples"
|
210
|
+
```
|
211
|
+
|
212
|
+
or you can supply them as an argument to the `translate` function:
|
213
|
+
|
182
214
|
```javascript
|
183
|
-
|
184
|
-
"hello".t({ name: "JS" }) => "Hello JS!"
|
215
|
+
const translations = { "hello": "Hello {name}!", "apple": { "one": "{count} apple", "other": "{count} apples" } };
|
185
216
|
|
186
|
-
|
217
|
+
I18n.t("hello", { "name": "JS"}, translations) => "Hello JS!"
|
218
|
+
I18n.t("apple", { count: 5 }, translations) => "5 apples"
|
187
219
|
```
|
data/lib/install/l10n.js
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
const I18n = {
|
2
|
+
translate: function(str, options, data) {
|
3
|
+
options = options || {};
|
4
|
+
var fallback = options['fallback'] || ('Translation missing: ' + str); // default is a JS reserved word
|
5
|
+
var translation, matches, method, match, interpolation_value;
|
6
|
+
var count = options['count'];
|
7
|
+
var keys = str.split('.');
|
8
|
+
var obj = data || this.translations;
|
9
|
+
|
10
|
+
var isString = function(value) {
|
11
|
+
return typeof value === 'string' || value instanceof String;
|
12
|
+
};
|
13
|
+
|
14
|
+
var isObject = function(value) {
|
15
|
+
return value && typeof value === 'object' && value.constructor === Object;
|
16
|
+
};
|
17
|
+
|
18
|
+
while(obj && keys.length) obj = obj[keys.shift()];
|
19
|
+
if (obj) {
|
20
|
+
if (isObject(obj) && count !== undefined) {
|
21
|
+
translation = obj[1 == count ? 'one' : 'other'];
|
22
|
+
} else {
|
23
|
+
translation = obj;
|
24
|
+
}
|
25
|
+
if (isString(translation) && (matches = translation.match(/{\w+?}/g))) {
|
26
|
+
while(match = matches.shift()) {
|
27
|
+
method = match.substr(1, match.length - 2);
|
28
|
+
interpolation_value = options[method];
|
29
|
+
if (interpolation_value == undefined) interpolation_value = ('undefined interpolation value: ' + method);
|
30
|
+
translation = translation.replace(new RegExp(match, 'g'), interpolation_value);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
return translation || fallback;
|
35
|
+
},
|
36
|
+
|
37
|
+
t: function(str, options, data) {
|
38
|
+
return this.translate(str, options, data);
|
39
|
+
},
|
40
|
+
|
41
|
+
translations: {}
|
42
|
+
|
43
|
+
};
|
44
|
+
|
45
|
+
export default I18n;
|
@@ -25,14 +25,16 @@ module L10n
|
|
25
25
|
end
|
26
26
|
|
27
27
|
module Formatting
|
28
|
-
|
29
|
-
def to_formatted_s(format = :rounded, options = nil)
|
28
|
+
def to_localized_formatted_s(format = :rounded, options = nil)
|
30
29
|
if options.nil? && format.is_a?(Hash)
|
31
30
|
options = format
|
32
31
|
format = :rounded
|
33
32
|
end
|
34
|
-
|
33
|
+
options ||= {}
|
34
|
+
options[:locale] ||= I18n.locale
|
35
|
+
to_fs(format, options)
|
35
36
|
end
|
37
|
+
alias_method :to_lfs, :to_localized_formatted_s
|
36
38
|
end
|
37
39
|
|
38
40
|
end
|
@@ -40,13 +42,7 @@ module L10n
|
|
40
42
|
end
|
41
43
|
|
42
44
|
Numeric.extend L10n::CoreExtensions::NumericExt::ClassMethods
|
43
|
-
|
44
|
-
# Ruby 2.4+ unifies Fixnum & Bignum into Integer.
|
45
|
-
numerics = 0.class == Integer ? [Integer] : [Fixnum, Bignum]
|
46
|
-
numerics << Float
|
47
|
-
numerics << Rational
|
48
|
-
|
49
|
-
numerics.each do |klass|
|
45
|
+
[Integer, Float, BigDecimal, Rational].each do |klass|
|
50
46
|
klass.include L10n::CoreExtensions::NumericExt::Localization
|
51
47
|
klass.prepend L10n::CoreExtensions::NumericExt::Formatting
|
52
48
|
end
|
data/lib/l10n/forms.rb
CHANGED
@@ -3,6 +3,7 @@ module L10n
|
|
3
3
|
module FormBuilder
|
4
4
|
|
5
5
|
def amount_field(field, options = {})
|
6
|
+
options = objectify_options(options)
|
6
7
|
format_options = options.extract!(:locale, :precision, :significant, :separator, :delimiter, :strip_insignificant_zeros)
|
7
8
|
value = L10n.number_to_rounded(object.public_send(field), format_options)
|
8
9
|
options[:value] = value
|
data/lib/l10n/i18n_extensions.rb
CHANGED
data/lib/l10n/railtie.rb
ADDED
data/lib/l10n/version.rb
CHANGED
data/lib/l10n.rb
CHANGED
@@ -6,19 +6,22 @@ require 'action_dispatch'
|
|
6
6
|
require 'active_support/all'
|
7
7
|
|
8
8
|
require_relative 'l10n/version'
|
9
|
-
require_relative 'l10n/core_extensions'
|
9
|
+
require_relative 'l10n/core_extensions/object_ext'
|
10
|
+
require_relative 'l10n/core_extensions/string_ext'
|
11
|
+
require_relative 'l10n/core_extensions/symbol_ext'
|
12
|
+
require_relative 'l10n/core_extensions/date_time_ext'
|
13
|
+
require_relative 'l10n/core_extensions/numeric_ext'
|
10
14
|
require_relative 'l10n/i18n_extensions'
|
11
|
-
require_relative 'l10n/inflections'
|
15
|
+
#require_relative 'l10n/inflections'
|
12
16
|
require_relative 'l10n/numeric_column_conversions'
|
13
17
|
require_relative 'l10n/column_translation'
|
14
18
|
require_relative 'l10n/translation_validator'
|
15
19
|
require_relative 'l10n/forms'
|
16
|
-
require_relative 'l10n/javascript_helper'
|
17
20
|
require_relative 'l10n/request'
|
18
|
-
require_relative 'l10n/
|
21
|
+
require_relative 'l10n/railtie'
|
19
22
|
|
20
|
-
files = Dir[File.join(File.dirname(__FILE__), 'locales/*.yml')]
|
21
|
-
I18n.load_path.concat(files)
|
23
|
+
#files = Dir[File.join(File.dirname(__FILE__), 'locales/*.yml')]
|
24
|
+
#I18n.load_path.concat(files)
|
22
25
|
|
23
26
|
module L10n
|
24
27
|
|
data/lib/tasks/l10n.rake
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: l10n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthias Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -30,167 +30,108 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 7.0.0
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '7.1'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 7.0.0
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '7.1'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 7.0.0
|
54
54
|
- - "<"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '7.1'
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
63
|
+
version: 7.0.0
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
66
|
+
version: '7.1'
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: actionpack
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
73
|
+
version: 7.0.0
|
74
74
|
- - "<"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '7.1'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: 7.0.0
|
84
84
|
- - "<"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '
|
86
|
+
version: '7.1'
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: railties
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: 7.0.0
|
94
94
|
- - "<"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '7.1'
|
97
97
|
type: :runtime
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 7.0.0
|
104
104
|
- - "<"
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version: '
|
107
|
-
- !ruby/object:Gem::Dependency
|
108
|
-
name: sqlite3
|
109
|
-
requirement: !ruby/object:Gem::Requirement
|
110
|
-
requirements:
|
111
|
-
- - ">="
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version: '0'
|
114
|
-
type: :development
|
115
|
-
prerelease: false
|
116
|
-
version_requirements: !ruby/object:Gem::Requirement
|
117
|
-
requirements:
|
118
|
-
- - ">="
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
version: '0'
|
121
|
-
- !ruby/object:Gem::Dependency
|
122
|
-
name: byebug
|
123
|
-
requirement: !ruby/object:Gem::Requirement
|
124
|
-
requirements:
|
125
|
-
- - ">="
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '0'
|
128
|
-
type: :development
|
129
|
-
prerelease: false
|
130
|
-
version_requirements: !ruby/object:Gem::Requirement
|
131
|
-
requirements:
|
132
|
-
- - ">="
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
version: '0'
|
135
|
-
- !ruby/object:Gem::Dependency
|
136
|
-
name: simplecov
|
137
|
-
requirement: !ruby/object:Gem::Requirement
|
138
|
-
requirements:
|
139
|
-
- - ">="
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
142
|
-
type: :development
|
143
|
-
prerelease: false
|
144
|
-
version_requirements: !ruby/object:Gem::Requirement
|
145
|
-
requirements:
|
146
|
-
- - ">="
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
version: '0'
|
149
|
-
- !ruby/object:Gem::Dependency
|
150
|
-
name: rake
|
151
|
-
requirement: !ruby/object:Gem::Requirement
|
152
|
-
requirements:
|
153
|
-
- - ">="
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
version: 0.8.7
|
156
|
-
type: :development
|
157
|
-
prerelease: false
|
158
|
-
version_requirements: !ruby/object:Gem::Requirement
|
159
|
-
requirements:
|
160
|
-
- - ">="
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
version: 0.8.7
|
106
|
+
version: '7.1'
|
163
107
|
description: Extensions for Rails I18n
|
164
108
|
email: mtgrosser@gmx.net
|
165
109
|
executables: []
|
166
110
|
extensions: []
|
167
111
|
extra_rdoc_files: []
|
168
112
|
files:
|
169
|
-
- CHANGELOG
|
170
|
-
-
|
113
|
+
- CHANGELOG.md
|
114
|
+
- LICENSE
|
171
115
|
- README.md
|
172
|
-
-
|
116
|
+
- lib/install/install.rb
|
117
|
+
- lib/install/l10n.js
|
173
118
|
- lib/l10n.rb
|
174
119
|
- lib/l10n/column_translation.rb
|
175
|
-
- lib/l10n/core_extensions.rb
|
176
|
-
- lib/l10n/core_extensions/big_decimal_ext.rb
|
177
120
|
- lib/l10n/core_extensions/date_time_ext.rb
|
178
121
|
- lib/l10n/core_extensions/numeric_ext.rb
|
179
122
|
- lib/l10n/core_extensions/object_ext.rb
|
180
123
|
- lib/l10n/core_extensions/string_ext.rb
|
181
124
|
- lib/l10n/core_extensions/symbol_ext.rb
|
182
|
-
- lib/l10n/engine.rb
|
183
125
|
- lib/l10n/forms.rb
|
184
126
|
- lib/l10n/i18n_extensions.rb
|
185
127
|
- lib/l10n/inflections.rb
|
186
|
-
- lib/l10n/javascript_helper.rb
|
187
128
|
- lib/l10n/numeric_column_conversions.rb
|
188
129
|
- lib/l10n/numericality_validator.rb
|
130
|
+
- lib/l10n/railtie.rb
|
189
131
|
- lib/l10n/request.rb
|
190
132
|
- lib/l10n/translation_validator.rb
|
191
133
|
- lib/l10n/version.rb
|
192
|
-
- lib/
|
193
|
-
- lib/locales/en.yml
|
134
|
+
- lib/tasks/l10n.rake
|
194
135
|
homepage: https://github.com/mtgrosser/l10n
|
195
136
|
licenses:
|
196
137
|
- MIT
|
@@ -210,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
151
|
- !ruby/object:Gem::Version
|
211
152
|
version: '0'
|
212
153
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
154
|
+
rubygems_version: 3.1.4
|
214
155
|
signing_key:
|
215
156
|
specification_version: 4
|
216
157
|
summary: Make I18n roar again
|
data/CHANGELOG
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
var I18n = I18n || {};
|
2
|
-
|
3
|
-
I18n.translate = function(str, options) {
|
4
|
-
options = options || {};
|
5
|
-
var fallback = options['fallback'] || ('Translation missing: ' + str); // default is a JS reserved word
|
6
|
-
var translation, matches, method, match, interpolation_value;
|
7
|
-
var count = options['count'];
|
8
|
-
var keys = str.split('.');
|
9
|
-
var obj = this.translations;
|
10
|
-
|
11
|
-
var isString = function(value) {
|
12
|
-
return typeof value === 'string' || value instanceof String;
|
13
|
-
};
|
14
|
-
|
15
|
-
var isObject = function(value) {
|
16
|
-
return value && typeof value === 'object' && value.constructor === Object;
|
17
|
-
};
|
18
|
-
|
19
|
-
while(obj && keys.length) obj = obj[keys.shift()];
|
20
|
-
if (obj) {
|
21
|
-
if (isObject(obj) && count !== undefined) {
|
22
|
-
translation = obj[1 == count ? 'one' : 'other'];
|
23
|
-
} else {
|
24
|
-
translation = obj;
|
25
|
-
}
|
26
|
-
if (isString(translation) && (matches = translation.match(/{\w+?}/g))) {
|
27
|
-
while(match = matches.shift()) {
|
28
|
-
method = match.substr(1, match.length - 2);
|
29
|
-
interpolation_value = options[method];
|
30
|
-
if (interpolation_value == undefined) interpolation_value = ('undefined interpolation value: ' + method);
|
31
|
-
translation = translation.replace(new RegExp(match, 'g'), interpolation_value);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
return translation || fallback;
|
36
|
-
};
|
37
|
-
|
38
|
-
I18n.t = function(str, options) {
|
39
|
-
return this.translate(str, options);
|
40
|
-
};
|
41
|
-
|
42
|
-
String.prototype.t = function(options){ return(I18n.translate(this, options)); }
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module L10n
|
2
|
-
module CoreExtensions
|
3
|
-
module BigDecimalExt
|
4
|
-
|
5
|
-
def to_localized_s
|
6
|
-
Numeric.localize(self)
|
7
|
-
end
|
8
|
-
|
9
|
-
def to_formatted_s(*args)
|
10
|
-
L10n.number_to_rounded(self, *args)
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
BigDecimal.prepend L10n::CoreExtensions::BigDecimalExt
|
data/lib/l10n/core_extensions.rb
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
require 'l10n/core_extensions/object_ext'
|
2
|
-
require 'l10n/core_extensions/string_ext'
|
3
|
-
require 'l10n/core_extensions/symbol_ext'
|
4
|
-
require 'l10n/core_extensions/date_time_ext'
|
5
|
-
require 'l10n/core_extensions/numeric_ext'
|
6
|
-
require 'l10n/core_extensions/big_decimal_ext'
|
data/lib/l10n/engine.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module L10n
|
2
|
-
module JavaScriptHelper
|
3
|
-
|
4
|
-
def i18n_script_tag
|
5
|
-
javascript_tag %<
|
6
|
-
var I18n = I18n || {};
|
7
|
-
|
8
|
-
I18n.locale = function() {
|
9
|
-
return("#{I18n.locale}");
|
10
|
-
};
|
11
|
-
|
12
|
-
I18n.translations = #{I18n.t(:javascript).to_json};
|
13
|
-
>
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
data/lib/locales/de.yml
DELETED