isomorfeus-i18n 1.0.0.delta11 → 1.0.0.delta12
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.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/lib/isomorfeus/i18n/version.rb +1 -1
- data/lib/lucid_translation/mixin.rb +119 -185
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8f296a3740f5e9885d04fd9bfe7c69e918382db5408e361c28b03812486d39
|
4
|
+
data.tar.gz: b6f4cc30d1622f4c16eebf50a99d2f1073ff3c19fe0936952bb5973eea6e93c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12b91afde9dbbf23240d97c86ac03c5d943d8db0e3152250200e8b99018506485b80cf43182f9903785176d2dfc8e812b438f81932e25df8753b833529cbdd00
|
7
|
+
data.tar.gz: 7abcb0c9c5566c798eec46e65f43a1051ce0709f17df11fa83c4ac672750c6ea09527ef6a4d43fb96d9162c4428bdcc94b065d87efefa9ac26f706d05f656b13
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# isomorfeus-i18n
|
2
|
+
|
3
|
+
Locale files go in my_app/isomorfeus/locales.
|
4
|
+
Supported formats: .mo, .po, .yml
|
5
|
+
|
6
|
+
Using fast_gettext internally.
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
In any class:
|
11
|
+
```
|
12
|
+
include LucidTranslation::Mixin
|
13
|
+
```
|
14
|
+
|
15
|
+
after which the _ gettext methods are available for translation.
|
16
|
+
See https://github.com/grosser/fast_gettext and https://rubydoc.info/gems/gettext/
|
@@ -12,219 +12,153 @@ module LucidTranslation
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if
|
24
|
-
|
25
|
-
|
26
|
-
`console.error(#{response[:agent_response][:error].to_n})`
|
27
|
-
raise response[:agent_response][:error]
|
28
|
-
end
|
29
|
-
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
30
|
-
end
|
15
|
+
if RUBY_ENGINE == 'opal'
|
16
|
+
def _(*keys, &block)
|
17
|
+
domain = Isomorfeus.i18n_domain
|
18
|
+
locale = Isomorfeus.locale
|
19
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, '_', keys)
|
20
|
+
return result if result
|
21
|
+
if Isomorfeus::I18n::Init.initialized?
|
22
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, '_', keys).then do |response|
|
23
|
+
if response[:agent_response].key?(:error)
|
24
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
25
|
+
raise response[:agent_response][:error]
|
31
26
|
end
|
32
|
-
|
27
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
33
28
|
end
|
29
|
+
end
|
30
|
+
block_given? ? block.call : keys.first
|
31
|
+
end
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
47
|
-
end
|
33
|
+
def n_(*keys, count, &block)
|
34
|
+
domain = Isomorfeus.i18n_domain
|
35
|
+
locale = Isomorfeus.locale
|
36
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, 'n_', keys + [count])
|
37
|
+
return result if result
|
38
|
+
if Isomorfeus::I18n::Init.initialized?
|
39
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, 'n_', keys + [count]).then do |response|
|
40
|
+
if response[:agent_response].key?(:error)
|
41
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
42
|
+
raise response[:agent_response][:error]
|
48
43
|
end
|
49
|
-
|
44
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
50
45
|
end
|
46
|
+
end
|
47
|
+
block_given? ? block.call : keys.last
|
48
|
+
end
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
block_given? ? block.call : n_(plural_one, *args)
|
58
|
-
end
|
50
|
+
def np_(context, plural_one, *args, separator: nil, &block)
|
51
|
+
nargs = ["#{context}#{separator || CONTEXT_SEPARATOR}#{plural_one}"] + args
|
52
|
+
translation = n_(*nargs, &NIL_BLOCK)
|
53
|
+
return translation if translation
|
59
54
|
|
60
|
-
|
61
|
-
|
62
|
-
locale = Isomorfeus.locale
|
63
|
-
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, 'ns_', args)
|
64
|
-
return result if result
|
65
|
-
if Isomorfeus::I18n::Init.initialized?
|
66
|
-
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, 'ns_', args).then do |response|
|
67
|
-
if response[:agent_response].key?(:error)
|
68
|
-
`console.error(#{response[:agent_response][:error].to_n})`
|
69
|
-
raise response[:agent_response][:error]
|
70
|
-
end
|
71
|
-
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
72
|
-
end
|
73
|
-
end
|
74
|
-
block_given? ? block.call : n_(*args).split(NAMESPACE_SEPARATOR).last
|
75
|
-
end
|
55
|
+
block_given? ? block.call : n_(plural_one, *args)
|
56
|
+
end
|
76
57
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
raise response[:agent_response][:error]
|
88
|
-
end
|
89
|
-
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
90
|
-
end
|
58
|
+
def ns_(*args, &block)
|
59
|
+
domain = Isomorfeus.i18n_domain
|
60
|
+
locale = Isomorfeus.locale
|
61
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, 'ns_', args)
|
62
|
+
return result if result
|
63
|
+
if Isomorfeus::I18n::Init.initialized?
|
64
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, 'ns_', args).then do |response|
|
65
|
+
if response[:agent_response].key?(:error)
|
66
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
67
|
+
raise response[:agent_response][:error]
|
91
68
|
end
|
92
|
-
|
69
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
93
70
|
end
|
71
|
+
end
|
72
|
+
block_given? ? block.call : n_(*args).split(NAMESPACE_SEPARATOR).last
|
73
|
+
end
|
94
74
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
108
|
-
end
|
75
|
+
def p_(namespace, key, separator = nil, &block)
|
76
|
+
domain = Isomorfeus.i18n_domain
|
77
|
+
locale = Isomorfeus.locale
|
78
|
+
args = separator ? [namespace, key, separator] : [namespace, key]
|
79
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, 'p_', args)
|
80
|
+
return result if result
|
81
|
+
if Isomorfeus::I18n::Init.initialized?
|
82
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, 'p_', args).then do |response|
|
83
|
+
if response[:agent_response].key?(:error)
|
84
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
85
|
+
raise response[:agent_response][:error]
|
109
86
|
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
def N_(translate)
|
114
|
-
translate
|
87
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
115
88
|
end
|
89
|
+
end
|
90
|
+
block_given? ? block.call : key
|
91
|
+
end
|
116
92
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
Isomorfeus.i18n_domain = old_domain
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
define_singleton_method("D#{method}") do |*args, &block|
|
133
|
-
domain = Isomorfeus.i18n_domain
|
134
|
-
locale = Isomorfeus.locale
|
135
|
-
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, "D#{method}", args)
|
136
|
-
return result if result
|
137
|
-
if Isomorfeus::I18n::Init.initialized?
|
138
|
-
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, "D#{method}", args).then do |response|
|
139
|
-
if response[:agent_response].key?(:error)
|
140
|
-
`console.error(#{response[:agent_response][:error].to_n})`
|
141
|
-
raise response[:agent_response][:error]
|
142
|
-
end
|
143
|
-
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
144
|
-
end
|
145
|
-
end
|
146
|
-
block_given? ? block.call : send(method, *args, &block)
|
93
|
+
def s_(key, separator = nil, &block)
|
94
|
+
domain = Isomorfeus.i18n_domain
|
95
|
+
locale = Isomorfeus.locale
|
96
|
+
args = separator ? [key, separator] : [key]
|
97
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, 's_', args)
|
98
|
+
return result if result
|
99
|
+
if Isomorfeus::I18n::Init.initialized?
|
100
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, 's_', args).then do |response|
|
101
|
+
if response[:agent_response].key?(:error)
|
102
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
103
|
+
raise response[:agent_response][:error]
|
147
104
|
end
|
105
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
148
106
|
end
|
149
107
|
end
|
108
|
+
block_given? ? block.call : key.split(separator || NAMESPACE_SEPARATOR).last
|
109
|
+
end
|
150
110
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
def n_(*args, &block)
|
156
|
-
self.class.n_(*args, &block)
|
157
|
-
end
|
158
|
-
|
159
|
-
def np_(*args, &block)
|
160
|
-
self.class.np_(*args, &block)
|
161
|
-
end
|
162
|
-
|
163
|
-
def ns_(*args, &block)
|
164
|
-
self.class.n_(*args, &block)
|
165
|
-
end
|
166
|
-
|
167
|
-
def p_(*args, &block)
|
168
|
-
self.class.p_(*args, &block)
|
169
|
-
end
|
170
|
-
|
171
|
-
def s(*args, &block)
|
172
|
-
self.class.s_(*args, &block)
|
173
|
-
end
|
174
|
-
|
175
|
-
def N_(translate)
|
176
|
-
translate
|
177
|
-
end
|
178
|
-
|
179
|
-
def Nn_(*keys)
|
180
|
-
keys
|
181
|
-
end
|
111
|
+
def N_(translate)
|
112
|
+
translate
|
113
|
+
end
|
182
114
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
self.class.send("d#{method}", domain, *args, &block)
|
187
|
-
end
|
115
|
+
def Nn_(*keys)
|
116
|
+
keys
|
117
|
+
end
|
188
118
|
|
189
|
-
|
190
|
-
|
119
|
+
TRANSLATION_METHODS.each do |method|
|
120
|
+
define_method("d#{method}") do |domain, *args, &block|
|
121
|
+
old_domain = Isomorfeus.i18n_domain
|
122
|
+
begin
|
123
|
+
Isomorfeus.i18n_domain = domain
|
124
|
+
send(method, *args, &block)
|
125
|
+
ensure
|
126
|
+
Isomorfeus.i18n_domain = old_domain
|
191
127
|
end
|
192
128
|
end
|
193
|
-
else
|
194
|
-
base.instance_exec do
|
195
|
-
TRANSLATION_METHODS.each do |method|
|
196
|
-
define_singleton_method(method) do |*args, &block|
|
197
|
-
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
198
|
-
InternalTranslationProxy.send(method, *args, &block)
|
199
|
-
end
|
200
129
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
130
|
+
define_method("D#{method}") do |*args, &block|
|
131
|
+
domain = Isomorfeus.i18n_domain
|
132
|
+
locale = Isomorfeus.locale
|
133
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, "D#{method}", args)
|
134
|
+
return result if result
|
135
|
+
if Isomorfeus::I18n::Init.initialized?
|
136
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, "D#{method}", args).then do |response|
|
137
|
+
if response[:agent_response].key?(:error)
|
138
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
139
|
+
raise response[:agent_response][:error]
|
140
|
+
end
|
141
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
209
142
|
end
|
210
143
|
end
|
144
|
+
block_given? ? block.call : send(method, *args, &block)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
else
|
148
|
+
TRANSLATION_METHODS.each do |method|
|
149
|
+
define_method(method) do |domain, *args, &block|
|
150
|
+
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
151
|
+
InternalTranslationProxy.send(method, domain, *args, &block)
|
211
152
|
end
|
212
153
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
end
|
218
|
-
|
219
|
-
define_method("d#{method}") do |domain, *args, &block|
|
220
|
-
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
221
|
-
InternalTranslationProxy.send("d#{method}", domain, *args, &block)
|
222
|
-
end
|
154
|
+
define_method("d#{method}") do |domain, *args, &block|
|
155
|
+
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
156
|
+
InternalTranslationProxy.send("d#{method}", domain, *args, &block)
|
157
|
+
end
|
223
158
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
end
|
159
|
+
define_method("D#{method}") do |*args, &block|
|
160
|
+
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
161
|
+
InternalTranslationProxy.send("D#{method}", *args, &block)
|
228
162
|
end
|
229
163
|
end
|
230
164
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.delta12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -128,28 +128,28 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.0.0.
|
131
|
+
version: 1.0.0.delta12
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.0.0.
|
138
|
+
version: 1.0.0.delta12
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: isomorfeus-data
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.0.0.
|
145
|
+
version: 1.0.0.delta12
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.0.0.
|
152
|
+
version: 1.0.0.delta12
|
153
153
|
description: I18n for Isomorfeus.
|
154
154
|
email: jan@kursator.de
|
155
155
|
executables: []
|
@@ -157,6 +157,7 @@ extensions: []
|
|
157
157
|
extra_rdoc_files: []
|
158
158
|
files:
|
159
159
|
- LICENSE
|
160
|
+
- README.md
|
160
161
|
- lib/isomorfeus-i18n.rb
|
161
162
|
- lib/isomorfeus/i18n/config.rb
|
162
163
|
- lib/isomorfeus/i18n/handler/locale_handler.rb
|