opal-i18next 0.3.0 → 0.4.0
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/opal/i18next/i18next.rb +159 -62
- data/opal/i18next/version.rb +1 -1
- data/opal-i18next.gemspec +6 -6
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7fcbdd82651c265dc9b07aad0f56ae5dc80b13562e69904c7083d75d297fafed
|
|
4
|
+
data.tar.gz: 31bc9a0cd604bdc2b911290fd3aa7659dde49782ef8f02f2dee0cbd5df3618f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c81f84936adae8165b9519651d66ca0ffc84b472f1315793fd83157fa0c4bf3473760cef76fd500873544a52414de0cbbc0f09c5b423b8988b1078ba1e9bc0e4
|
|
7
|
+
data.tar.gz: 26dd77f60baf03f73791cf3dead57f98a5d8369b8ff60bda0e3c2ebe33767c188580469668b2a3fff08023d4337dfa4f01695053f1d7aacd47462b7704f2b9e4
|
data/opal/i18next/i18next.rb
CHANGED
|
@@ -8,37 +8,50 @@ module I18next
|
|
|
8
8
|
|
|
9
9
|
Promise = defined?(PromiseV2) ? PromiseV2 : ::Promise
|
|
10
10
|
|
|
11
|
-
# {I18next} is a basic wrapper around the JavaScript {https://www.i18next.com i18next
|
|
11
|
+
# {I18next} is a basic wrapper around the JavaScript I18N module {https://www.i18next.com i18next}.
|
|
12
12
|
#
|
|
13
|
-
# It wraps i18next
|
|
14
|
-
# {https://www.i18next.com/overview/api#
|
|
15
|
-
# {https://www.i18next.com/overview/api#
|
|
13
|
+
# It wraps i18next functions {https://www.i18next.com/overview/api#addresource addResource},
|
|
14
|
+
# {https://www.i18next.com/overview/api#addresourcebundle addResourceBundle},
|
|
15
|
+
# {https://www.i18next.com/overview/api#addresources addResources},
|
|
16
16
|
# {https://www.i18next.com/overview/api#changelanguage changeLanguage},
|
|
17
|
+
# {https://www.i18next.com/overview/api#cloneinstance cloneInstance},
|
|
17
18
|
# {https://www.i18next.com/overview/api#dir dir},
|
|
18
19
|
# {https://www.i18next.com/overview/api#exists exists},
|
|
19
|
-
# {https://www.i18next.com/overview/api#
|
|
20
|
-
# {https://www.i18next.com/overview/api#
|
|
21
|
-
# {https://www.i18next.com/overview/api#
|
|
22
|
-
# {https://www.i18next.com/overview/api#
|
|
23
|
-
# {https://www.i18next.com/overview/api#
|
|
20
|
+
# {https://www.i18next.com/overview/api#getdatabylanguage getDataByLanguage},
|
|
21
|
+
# {https://www.i18next.com/overview/api#getfixedt getFixedT},
|
|
22
|
+
# {https://www.i18next.com/overview/api#getresource getResource},
|
|
23
|
+
# {https://www.i18next.com/overview/api#getresourcebundle getResourceBundle},
|
|
24
|
+
# {https://www.i18next.com/overview/api#hasresourcebundle hasResourceBundle},
|
|
24
25
|
# {https://www.i18next.com/overview/api#init init},
|
|
25
26
|
# {https://www.i18next.com/overview/api#language language},
|
|
26
27
|
# {https://www.i18next.com/overview/api#languages languages},
|
|
27
|
-
# {https://www.i18next.com/overview/api#
|
|
28
|
-
# {https://www.i18next.com/overview/api#
|
|
28
|
+
# {https://www.i18next.com/overview/api#loadlanguages loadLanguages},
|
|
29
|
+
# {https://www.i18next.com/overview/api#loadnamespaces loadNamespaces},
|
|
29
30
|
# {https://www.i18next.com/overview/api#events off},
|
|
30
31
|
# {https://www.i18next.com/overview/api#events on},
|
|
31
|
-
# {https://www.i18next.com/overview/api#
|
|
32
|
-
# {https://www.i18next.com/overview/api#
|
|
33
|
-
# {https://www.i18next.com/overview/api#
|
|
34
|
-
# {https://www.i18next.com/overview/api#
|
|
32
|
+
# {https://www.i18next.com/overview/api#reloadresources reloadResources},
|
|
33
|
+
# {https://www.i18next.com/overview/api#removeresourcebundle removeResourceBundle},
|
|
34
|
+
# {https://www.i18next.com/overview/api#resolvedlanguage resolvedLanguage},
|
|
35
|
+
# {https://www.i18next.com/overview/api#setdefaultnamespace setDefaultNamespace},
|
|
36
|
+
# {https://www.i18next.com/overview/api#store-events store.on},
|
|
35
37
|
# {https://www.i18next.com/overview/api#t t}, and
|
|
36
38
|
# {https://www.i18next.com/overview/api#use use}.
|
|
37
39
|
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
+
# Function {https://www.i18next.com/overview/api#createinstance createInstance}
|
|
41
|
+
# is not supported because each I18next::I18next instance has its own
|
|
42
|
+
# JavaScript i18next module instance. To create a new instance use
|
|
43
|
+
# I18next::I18next.new.
|
|
40
44
|
#
|
|
41
|
-
#
|
|
45
|
+
# Function {https://www.i18next.com/overview/api#format format} is not supported
|
|
46
|
+
# because it is a legacy function that has been superseded by
|
|
47
|
+
# {https://www.i18next.com/translation-function/formatting built-in formatting
|
|
48
|
+
# functions}.
|
|
49
|
+
#
|
|
50
|
+
# It can handle {https://www.i18next.com/overview/api#events i18next events}.
|
|
51
|
+
# See methods {#on} and {#off}.
|
|
52
|
+
#
|
|
53
|
+
# It also provides method {#import_js_module} for loading
|
|
54
|
+
# {https://www.i18next.com/overview/plugins-and-utils i18next plugins}.
|
|
42
55
|
class I18next
|
|
43
56
|
|
|
44
57
|
# Each I18next instance has its own i18next Javascript module
|
|
@@ -54,7 +67,7 @@ module I18next
|
|
|
54
67
|
# @param module_path [String] the path to the module's *.js file, may be a
|
|
55
68
|
# file path or a URL
|
|
56
69
|
#
|
|
57
|
-
# @return [Promise] a promise that resolves to
|
|
70
|
+
# @return [Promise] a promise that resolves to a JavaScript module that can be passed
|
|
58
71
|
# to the {#use} method
|
|
59
72
|
#
|
|
60
73
|
def import_js_module(module_path)
|
|
@@ -68,18 +81,19 @@ module I18next
|
|
|
68
81
|
promise
|
|
69
82
|
end
|
|
70
83
|
|
|
71
|
-
# Loads an {https://www.i18next.com/overview/
|
|
84
|
+
# Loads an {https://www.i18next.com/overview/plugins-and-utils i18next plugin}
|
|
72
85
|
#
|
|
73
|
-
# @param js_module a plugin's JavaScript module that was imported
|
|
86
|
+
# @param js_module [Object] a plugin's JavaScript module that was imported
|
|
74
87
|
# by method {#import_js_module}
|
|
75
88
|
# @return [I18next::I18next] self
|
|
89
|
+
# @see https://www.i18next.com/overview/api#use The i18next use function
|
|
76
90
|
def use(js_module)
|
|
77
91
|
`#{@i18next}.use(js_module.default)`
|
|
78
92
|
self
|
|
79
93
|
end
|
|
80
94
|
|
|
81
95
|
# Initializes {https://www.i18next.com/overview/api#init i18next}
|
|
82
|
-
# @param options [Hash] a hash with keys matching the {https://www.i18next.com/overview/configuration-options i18next options}
|
|
96
|
+
# @param options [Hash] a hash with keys matching the {https://www.i18next.com/overview/configuration-options i18next options}
|
|
83
97
|
# @return [Promise] a promise that resolves when i18next has been initialized
|
|
84
98
|
def init(options = {})
|
|
85
99
|
promise = Promise.new
|
|
@@ -97,6 +111,7 @@ module I18next
|
|
|
97
111
|
# @param language [String] the new language
|
|
98
112
|
# @return [Promise] a promise that resolves when the language's
|
|
99
113
|
# translations have been loaded
|
|
114
|
+
# @see https://www.i18next.com/overview/api#changelanguage The i18next changeLanguage function
|
|
100
115
|
def change_language(language)
|
|
101
116
|
promise = Promise.new
|
|
102
117
|
`
|
|
@@ -108,7 +123,8 @@ module I18next
|
|
|
108
123
|
promise
|
|
109
124
|
end
|
|
110
125
|
|
|
111
|
-
# @return [String] the current
|
|
126
|
+
# @return [String] the current language
|
|
127
|
+
# @see https://www.i18next.com/overview/api#language The i18next language function
|
|
112
128
|
def language
|
|
113
129
|
`#{@i18next}.language`
|
|
114
130
|
end
|
|
@@ -117,23 +133,25 @@ module I18next
|
|
|
117
133
|
# @param [String, Array<String>] key one or more keys that reference translations
|
|
118
134
|
# @param [Hash] options options for formatters, post processors, etc.
|
|
119
135
|
# @return [String] the translation associated with the first key that resolves
|
|
136
|
+
# @see https://www.i18next.com/overview/api#t The i18next t function
|
|
120
137
|
def t(key, options={})
|
|
121
138
|
`#{@i18next}.t(key, #{options.to_n})`
|
|
122
139
|
end
|
|
123
140
|
|
|
124
141
|
# @return [Boolean] true if the key exists
|
|
142
|
+
# @see https://www.i18next.com/overview/api#exists The i18next exists function
|
|
125
143
|
def exists(key)
|
|
126
144
|
`#{@i18next}.exists(key)`
|
|
127
145
|
end
|
|
128
146
|
|
|
129
|
-
# Returns a Proc that acts a +t+ method that defaults to a language and namespace.
|
|
130
|
-
# @example When calling the returned Proc, use brackets, not parentheses
|
|
147
|
+
# Returns a Proc that acts as a +t+ method that defaults to a language and namespace.
|
|
148
|
+
# @example When calling the returned Proc, use brackets, not parentheses:
|
|
131
149
|
# en = get_fixed_t("en")
|
|
132
150
|
# translation = en["key"]
|
|
133
151
|
# @param lng [String] language
|
|
134
152
|
# @param ns [String] namespace
|
|
135
153
|
# @param key_prefix [String] key prefix
|
|
136
|
-
# @see https://www.i18next.com/overview/api#
|
|
154
|
+
# @see https://www.i18next.com/overview/api#getfixedt The i18next getFixedT function
|
|
137
155
|
def get_fixed_t(lng = nil, ns = nil, key_prefix = nil)
|
|
138
156
|
if key_prefix && ns && lng
|
|
139
157
|
`#{@i18next}.getFixedT(lng, ns, key_prefix)`
|
|
@@ -146,13 +164,13 @@ module I18next
|
|
|
146
164
|
end
|
|
147
165
|
end
|
|
148
166
|
|
|
149
|
-
# @see https://www.i18next.com/overview/api#languages The i18next languages
|
|
167
|
+
# @see https://www.i18next.com/overview/api#languages The i18next languages function
|
|
150
168
|
# @return language codes that will be used to look up the translation value
|
|
151
169
|
def languages
|
|
152
170
|
`#{@i18next}.languages`
|
|
153
171
|
end
|
|
154
172
|
|
|
155
|
-
# @see https://www.i18next.com/overview/api#
|
|
173
|
+
# @see https://www.i18next.com/overview/api#resolvedlanguage The i18next resolvedLanguage function
|
|
156
174
|
# @return the current resolved language
|
|
157
175
|
def resolved_language
|
|
158
176
|
`#{@i18next}.resolvedLanguage`
|
|
@@ -161,7 +179,7 @@ module I18next
|
|
|
161
179
|
# Loads additional namespaces not defined in init options
|
|
162
180
|
# @param ns [String, Array<String>] one or more namespaces
|
|
163
181
|
# @return [Promise] a promise that resolves when the namespaces have been loaded
|
|
164
|
-
# @see https://www.i18next.com/overview/api#
|
|
182
|
+
# @see https://www.i18next.com/overview/api#loadnamespaces The i18next loadNamespaces function
|
|
165
183
|
def load_namespaces(ns)
|
|
166
184
|
promise = Promise.new
|
|
167
185
|
`
|
|
@@ -177,7 +195,7 @@ module I18next
|
|
|
177
195
|
# Loads additional languages not defined in init options (preload).
|
|
178
196
|
# @param lngs [String, Array<String>] one or more languages
|
|
179
197
|
# @return [Promise] a promise that resolves when the languages have been loaded
|
|
180
|
-
# @see https://www.i18next.com/overview/api#
|
|
198
|
+
# @see https://www.i18next.com/overview/api#loadlanguages The i18next loadLanguages function
|
|
181
199
|
def load_languages(lngs)
|
|
182
200
|
promise = Promise.new
|
|
183
201
|
`
|
|
@@ -190,14 +208,29 @@ module I18next
|
|
|
190
208
|
promise
|
|
191
209
|
end
|
|
192
210
|
|
|
193
|
-
#
|
|
194
|
-
|
|
195
|
-
|
|
211
|
+
# Reloads resources on given state.
|
|
212
|
+
#
|
|
213
|
+
# Optionally you can pass an array of languages and/or namespaces as params if
|
|
214
|
+
# you don't want to reload all.
|
|
215
|
+
# @param lng [String, Array<String>] one or more languages
|
|
216
|
+
# @param ns [String, Array<String>] one or more namespaces
|
|
217
|
+
# @return [Promise] a promise that resolves when the resources have been loaded
|
|
218
|
+
# @see https://www.i18next.com/overview/api#reloadresources The i18next reloadResources function
|
|
219
|
+
def reload_resources(lng = nil, ns = nil)
|
|
220
|
+
if !lng && !ns
|
|
221
|
+
reload_all_resources
|
|
222
|
+
elsif lng && !ns
|
|
223
|
+
reload_lng_resources(lng)
|
|
224
|
+
elsif !lng && ns
|
|
225
|
+
reload_ns_resources(ns)
|
|
226
|
+
else
|
|
227
|
+
reload_lng_ns_resources(lng, ns)
|
|
228
|
+
end
|
|
196
229
|
end
|
|
197
230
|
|
|
198
231
|
# Changes the default namespace.
|
|
199
232
|
# @param ns [String] new default namespace
|
|
200
|
-
# @see https://www.i18next.com/overview/api#
|
|
233
|
+
# @see https://www.i18next.com/overview/api#setdefaultnamespace The i18next setDefaultNamespace function
|
|
201
234
|
def set_default_namespace(ns)
|
|
202
235
|
`#{@i18next}.setDefaultNamespace(ns)`
|
|
203
236
|
end
|
|
@@ -205,51 +238,40 @@ module I18next
|
|
|
205
238
|
# Get a language's reading direction
|
|
206
239
|
# @param lng [String] the language; if omitted, the current language is used
|
|
207
240
|
# @return "ltr" or "rtl"
|
|
208
|
-
# @see https://www.i18next.com/overview/api#dir The i18next dir
|
|
241
|
+
# @see https://www.i18next.com/overview/api#dir The i18next dir function
|
|
209
242
|
def dir(lng)
|
|
210
243
|
`#{@i18next}.dir(lng)`
|
|
211
244
|
end
|
|
212
245
|
|
|
213
|
-
# @private
|
|
214
|
-
def format(data, format, lng)
|
|
215
|
-
raise 'Not implemented'
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
# @private
|
|
219
|
-
def create_instance(options)
|
|
220
|
-
raise 'Not implemented'
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
# @private
|
|
224
|
-
def clone_instance(options)
|
|
225
|
-
raise 'Not implemented'
|
|
226
|
-
end
|
|
227
|
-
|
|
228
246
|
# Gets one value by given key.
|
|
229
|
-
# @
|
|
247
|
+
# @param lng [String] language
|
|
248
|
+
# @param ns [String] namespace
|
|
249
|
+
# @param key_prefix [String] key prefix
|
|
250
|
+
# @param options [Hash] key separator and ignore JSON structure
|
|
251
|
+
# @see https://www.i18next.com/overview/api#getresource The i18next getResource function
|
|
230
252
|
def get_resource(lng, ns, key, options = {})
|
|
231
253
|
`#{@i18next}.getResource(lng, ns, key, options)`
|
|
232
254
|
end
|
|
233
255
|
|
|
234
256
|
# Adds one key/value.
|
|
235
|
-
# @see https://www.i18next.com/overview/api#
|
|
257
|
+
# @see https://www.i18next.com/overview/api#addresource The i18next addResource function
|
|
236
258
|
def add_resource(lng, ns, key, value, options = {})
|
|
237
259
|
`#{@i18next}.addResource(lng, ns, key, value, options)`
|
|
238
260
|
end
|
|
239
261
|
|
|
240
262
|
# Adds multiple key/values.
|
|
241
263
|
# @param resources [Hash] key/value pairs
|
|
242
|
-
# @see https://www.i18next.com/overview/api#
|
|
264
|
+
# @see https://www.i18next.com/overview/api#addresources The i18next addResources function
|
|
243
265
|
def add_resources(lng, ns, resources)
|
|
244
266
|
`#{@i18next}.addResources(lng, ns, #{resources.to_n})`
|
|
245
267
|
end
|
|
246
268
|
|
|
247
269
|
# Adds a complete bundle
|
|
248
270
|
# @param lng [String] bundle language
|
|
249
|
-
# @param ns [String]
|
|
271
|
+
# @param ns [String] bundle namespace
|
|
250
272
|
# @param deep [Boolean] if true will extend existing translations in the bundle
|
|
251
273
|
# @param overwrite [Boolean] if true it will overwrite existing translations in the bundle
|
|
252
|
-
# @see https://www.i18next.com/overview/api#
|
|
274
|
+
# @see https://www.i18next.com/overview/api#addresourcebundle The i18next addResourceBundle function
|
|
253
275
|
def add_resource_bundle(lng, ns, resources, deep = false, overwrite = false)
|
|
254
276
|
`#{@i18next}.addResources(lng, ns, #{resources.to_n}, deep, overwrite)`
|
|
255
277
|
end
|
|
@@ -257,21 +279,24 @@ module I18next
|
|
|
257
279
|
# Checks if a resource bundle exists
|
|
258
280
|
# @param lng [String] language
|
|
259
281
|
# @param ns [String] namespace
|
|
282
|
+
# @return [Boolean] true if the bundle exists
|
|
260
283
|
def has_resource_bundle(lng, ns)
|
|
261
284
|
`#{@i18next}.hasResourceBundle(lng, ns)`
|
|
262
285
|
end
|
|
263
286
|
|
|
264
287
|
# Returns resource data for a language.
|
|
265
288
|
# @param lng [String] language
|
|
266
|
-
# @return resource data
|
|
267
|
-
# @see https://www.i18next.com/overview/api#
|
|
289
|
+
# @return [Hash] resource data
|
|
290
|
+
# @see https://www.i18next.com/overview/api#getbatabylanguage The i18next getDataByLanguage function
|
|
268
291
|
def get_data_by_language(lng)
|
|
269
292
|
js_obj_to_ruby_hash(`#{@i18next}.getDataByLanguage(lng)`)
|
|
270
293
|
end
|
|
271
294
|
|
|
272
295
|
# Gets a resource bundle.
|
|
296
|
+
# @param lng [String] language
|
|
297
|
+
# @param ns [String] namespace
|
|
273
298
|
# @return [Hash] key/value pairs
|
|
274
|
-
# @see https://www.i18next.com/overview/api#
|
|
299
|
+
# @see https://www.i18next.com/overview/api#getresourcebundle The i18next getResourceBundle function
|
|
275
300
|
def get_resource_bundle(lng, ns)
|
|
276
301
|
js_obj_to_ruby_hash(`#{@i18next}.getResourceBundle(lng, ns)`)
|
|
277
302
|
end
|
|
@@ -279,6 +304,7 @@ module I18next
|
|
|
279
304
|
# Removes a resource bundle exists
|
|
280
305
|
# @param lng [String] language
|
|
281
306
|
# @param ns [String] namespace
|
|
307
|
+
# @see https://www.i18next.com/overview/api#removeresourcebundle The i18next removeResourceBundle function
|
|
282
308
|
def remove_resource_bundle(lng, ns)
|
|
283
309
|
`#{@i18next}.removeResourceBundle(lng, ns)`
|
|
284
310
|
end
|
|
@@ -286,7 +312,7 @@ module I18next
|
|
|
286
312
|
# Create a listener for an i18next event.
|
|
287
313
|
# @param event [String] event name
|
|
288
314
|
# @param &listener [block] an event listener that is passed event-dependent arguments
|
|
289
|
-
# @return [Proc]
|
|
315
|
+
# @return [Proc] a listener, which can be used to unsubscribe it via method +off(event, listener)+
|
|
290
316
|
# @see https://www.i18next.com/overview/api#events The i18next events
|
|
291
317
|
# @see #off
|
|
292
318
|
def on(event, &listener)
|
|
@@ -305,20 +331,24 @@ module I18next
|
|
|
305
331
|
|
|
306
332
|
# Create a listener for an i18next store event.
|
|
307
333
|
#
|
|
308
|
-
# Only available after the init call.
|
|
334
|
+
# Only available after the +init+ call.
|
|
309
335
|
#
|
|
310
336
|
# @param event [String] event name ("added" or "removed")
|
|
311
337
|
# @param &listener [block] an event listener that is passed language and namespace arguments
|
|
312
|
-
# @return [Proc] the listener, which can be
|
|
338
|
+
# @return [Proc] the listener, which can be unsubscribed via method +off(event, listener)+
|
|
313
339
|
# @see https://www.i18next.com/overview/api#store-events The i18next store events
|
|
314
340
|
def store_on(event, &listener)
|
|
315
341
|
`#{@i18next}.store.on(event, listener)`
|
|
316
342
|
listener
|
|
317
343
|
end
|
|
318
344
|
|
|
319
|
-
# Unsubscribes an event's listener(s)
|
|
345
|
+
# Unsubscribes an event's listener(s).
|
|
346
|
+
#
|
|
347
|
+
# Listeners are created by method {#on}.
|
|
320
348
|
# @param event [String] event name
|
|
321
349
|
# @param listener [Proc] the listener to unsubscribe; if absent, unsubscribe all listeners
|
|
350
|
+
# @see https://www.i18next.com/overview/api#events The i18next events
|
|
351
|
+
# @see #on
|
|
322
352
|
def off(event, listener = nil)
|
|
323
353
|
if listener
|
|
324
354
|
`#{@i18next}.off(event, listener)`
|
|
@@ -327,8 +357,75 @@ module I18next
|
|
|
327
357
|
end
|
|
328
358
|
end
|
|
329
359
|
|
|
360
|
+
# Creates a clone of the current instance.
|
|
361
|
+
#
|
|
362
|
+
# Shares store, plugins and initial configuration. Can be used to create an
|
|
363
|
+
# instance sharing storage but being independent on set language or default namespaces.
|
|
364
|
+
# @param options [Hash] a hash with keys matching the {https://www.i18next.com/overview/configuration-options i18next options}
|
|
365
|
+
# @return [I18next::I18next] a new instance
|
|
366
|
+
# @see https://www.i18next.com/overview/api#cloneinstance The i18next cloneInstance function
|
|
367
|
+
def clone_instance(options = {})
|
|
368
|
+
I18nextClone.new(@i18next, options)
|
|
369
|
+
end
|
|
370
|
+
|
|
330
371
|
private
|
|
331
372
|
|
|
373
|
+
# @private
|
|
374
|
+
class I18nextClone < I18next
|
|
375
|
+
def initialize(js_i18next, options)
|
|
376
|
+
@i18next = `#{js_i18next}.cloneInstance(#{options.to_n})`
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
# @private
|
|
381
|
+
def reload_all_resources
|
|
382
|
+
promise = Promise.new
|
|
383
|
+
`
|
|
384
|
+
#{@i18next}.reloadResources()
|
|
385
|
+
.then(
|
|
386
|
+
() => {
|
|
387
|
+
promise.$resolve()
|
|
388
|
+
});
|
|
389
|
+
`
|
|
390
|
+
promise
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
def reload_lng_resources(lng)
|
|
394
|
+
promise = Promise.new
|
|
395
|
+
`
|
|
396
|
+
#{@i18next}.reloadResources(lng)
|
|
397
|
+
.then(
|
|
398
|
+
() => {
|
|
399
|
+
promise.$resolve()
|
|
400
|
+
});
|
|
401
|
+
`
|
|
402
|
+
promise
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def reload_ns_resources(ns)
|
|
406
|
+
promise = Promise.new
|
|
407
|
+
`
|
|
408
|
+
#{@i18next}.reloadResources(null, ns)
|
|
409
|
+
.then(
|
|
410
|
+
() => {
|
|
411
|
+
promise.$resolve()
|
|
412
|
+
});
|
|
413
|
+
`
|
|
414
|
+
promise
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
def reload_lng_ns_resources(lng, ns)
|
|
418
|
+
promise = Promise.new
|
|
419
|
+
`
|
|
420
|
+
#{@i18next}.reloadResources(lng, ns)
|
|
421
|
+
.then(
|
|
422
|
+
() => {
|
|
423
|
+
promise.$resolve()
|
|
424
|
+
});
|
|
425
|
+
`
|
|
426
|
+
promise
|
|
427
|
+
end
|
|
428
|
+
|
|
332
429
|
# @private
|
|
333
430
|
# Create a listener for the i18next initialized event.
|
|
334
431
|
# @param &listener [Proc] an event listener block that is passed initialized options Hash
|
data/opal/i18next/version.rb
CHANGED
data/opal-i18next.gemspec
CHANGED
|
@@ -5,12 +5,12 @@ Gem::Specification.new do |spec|
|
|
|
5
5
|
spec.version = I18next::VERSION
|
|
6
6
|
spec.summary = "An Opal wrapper for the JavaScript i18next module."
|
|
7
7
|
spec.description = <<~DESC
|
|
8
|
-
A basic Opal wrapper for the JavaScript
|
|
9
|
-
addResource, addResourceBundle, addResources, changeLanguage,
|
|
10
|
-
getDataByLanguage, getFixedT, getResource, getResourceBundle,
|
|
11
|
-
init, language, languages, loadLanguages, loadNamespaces,
|
|
12
|
-
removeResourceBundle, resolvedLanguage, store.on,
|
|
13
|
-
provides method import_js_module for loading i18next plugins.
|
|
8
|
+
A basic Opal wrapper for the JavaScript I18N module i18next that supports functions
|
|
9
|
+
addResource, addResourceBundle, addResources, changeLanguage, cloneInstance,
|
|
10
|
+
dir, exists, getDataByLanguage, getFixedT, getResource, getResourceBundle,
|
|
11
|
+
hasResourceBundle, init, language, languages, loadLanguages, loadNamespaces,
|
|
12
|
+
off, on, reloadResources, removeResourceBundle, resolvedLanguage, store.on,
|
|
13
|
+
t, and use. It also provides method import_js_module for loading i18next plugins.
|
|
14
14
|
DESC
|
|
15
15
|
spec.authors = ["Larry North"]
|
|
16
16
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opal-i18next
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Larry North
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-09-
|
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: opal
|
|
@@ -25,12 +25,12 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 1.5.0
|
|
27
27
|
description: |
|
|
28
|
-
A basic Opal wrapper for the JavaScript
|
|
29
|
-
addResource, addResourceBundle, addResources, changeLanguage,
|
|
30
|
-
getDataByLanguage, getFixedT, getResource, getResourceBundle,
|
|
31
|
-
init, language, languages, loadLanguages, loadNamespaces,
|
|
32
|
-
removeResourceBundle, resolvedLanguage, store.on,
|
|
33
|
-
provides method import_js_module for loading i18next plugins.
|
|
28
|
+
A basic Opal wrapper for the JavaScript I18N module i18next that supports functions
|
|
29
|
+
addResource, addResourceBundle, addResources, changeLanguage, cloneInstance,
|
|
30
|
+
dir, exists, getDataByLanguage, getFixedT, getResource, getResourceBundle,
|
|
31
|
+
hasResourceBundle, init, language, languages, loadLanguages, loadNamespaces,
|
|
32
|
+
off, on, reloadResources, removeResourceBundle, resolvedLanguage, store.on,
|
|
33
|
+
t, and use. It also provides method import_js_module for loading i18next plugins.
|
|
34
34
|
email:
|
|
35
35
|
- lnorth@swnorth.com
|
|
36
36
|
executables: []
|