isomorfeus-i18n 1.0.0.zeta25 → 2.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +22 -22
- data/lib/isomorfeus/i18n/config.rb +78 -78
- data/lib/isomorfeus/i18n/handler/locale_handler.rb +76 -76
- data/lib/isomorfeus/i18n/init.rb +47 -47
- data/lib/isomorfeus/i18n/reducer.rb +38 -38
- data/lib/isomorfeus/i18n/version.rb +4 -4
- data/lib/isomorfeus-i18n.rb +72 -71
- data/lib/lucid_translation/mixin.rb +194 -194
- metadata +45 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7032f608527be3caa72c5c20c48e7386d2b51b2cccde7c1fd387a9938bb18836
|
4
|
+
data.tar.gz: af3b7fb2580e802149037186d32fe4332d3b97d87fcf4faf3acc92be5a8244a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0faaf586a55eeb7a93ada71da51afb3ce6cda0a5a333249ce686bf2440a5ff74f8081a386569145014f7ed50802069caa346ad0e44b7305861fcb2eb537a535f
|
7
|
+
data.tar.gz: 305785ef7efa2e4ca4ac560384984aab2a9e2e8b20bd3f26ba3ff8bd4baef4572a000a69ed584db90db668dad1999fd72c8e8b80f90bceb7de0c01d388b922ab
|
data/LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2018-2019 Jan Biedermann
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018-2019 Jan Biedermann
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
# isomorfeus-i18n
|
2
|
-
|
3
|
-
Internationalization for Isomorfeus.
|
4
|
-
|
5
|
-
### Community and Support
|
6
|
-
At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
7
|
-
|
8
|
-
### Usage
|
9
|
-
Locale files go in my_app/isomorfeus/locales.
|
10
|
-
Supported formats: .mo, .po, .yml
|
11
|
-
|
12
|
-
Using fast_gettext internally.
|
13
|
-
|
14
|
-
## Usage
|
15
|
-
|
16
|
-
In any class:
|
17
|
-
```
|
18
|
-
include LucidTranslation::Mixin
|
19
|
-
```
|
20
|
-
|
21
|
-
after which the _ gettext methods are available for translation.
|
22
|
-
See https://github.com/grosser/fast_gettext and https://rubydoc.info/gems/gettext/
|
1
|
+
# isomorfeus-i18n
|
2
|
+
|
3
|
+
Internationalization for Isomorfeus.
|
4
|
+
|
5
|
+
### Community and Support
|
6
|
+
At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
7
|
+
|
8
|
+
### Usage
|
9
|
+
Locale files go in my_app/isomorfeus/locales.
|
10
|
+
Supported formats: .mo, .po, .yml
|
11
|
+
|
12
|
+
Using fast_gettext internally.
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
In any class:
|
17
|
+
```
|
18
|
+
include LucidTranslation::Mixin
|
19
|
+
```
|
20
|
+
|
21
|
+
after which the _ gettext methods are available for translation.
|
22
|
+
See https://github.com/grosser/fast_gettext and https://rubydoc.info/gems/gettext/
|
@@ -1,78 +1,78 @@
|
|
1
|
-
module Isomorfeus
|
2
|
-
# available settings
|
3
|
-
class << self
|
4
|
-
attr_accessor :i18n_type
|
5
|
-
|
6
|
-
if RUBY_ENGINE == 'opal'
|
7
|
-
def available_locales
|
8
|
-
result = Redux.fetch_by_path(:i18n_state, :available_locales)
|
9
|
-
result ? result : ['en']
|
10
|
-
end
|
11
|
-
|
12
|
-
def i18n_domain
|
13
|
-
result = Redux.fetch_by_path(:i18n_state, :domain)
|
14
|
-
result ? result : 'app'
|
15
|
-
end
|
16
|
-
|
17
|
-
def i18n_domain=(domain)
|
18
|
-
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain: domain })
|
19
|
-
domain
|
20
|
-
end
|
21
|
-
|
22
|
-
def locale
|
23
|
-
result = Redux.fetch_by_path(:i18n_state, :locale)
|
24
|
-
result ? result : available_locales.first
|
25
|
-
end
|
26
|
-
|
27
|
-
def locale=(loc)
|
28
|
-
Isomorfeus.raise_error(message: "Locale #{loc} not available!") unless available_locales.include?(loc)
|
29
|
-
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { locale: locale })
|
30
|
-
loc
|
31
|
-
end
|
32
|
-
|
33
|
-
def negotiated_locale
|
34
|
-
@negotiated_locale
|
35
|
-
end
|
36
|
-
|
37
|
-
def negotiated_locale=(l)
|
38
|
-
@negotiated_locale = l
|
39
|
-
end
|
40
|
-
else
|
41
|
-
def available_locales
|
42
|
-
@available_locales
|
43
|
-
end
|
44
|
-
|
45
|
-
def available_locales=(locs_arr)
|
46
|
-
FastGettext.available_locales = locs_arr
|
47
|
-
@available_locales = locs_arr
|
48
|
-
end
|
49
|
-
|
50
|
-
def i18n_domain
|
51
|
-
@i18n_domain
|
52
|
-
end
|
53
|
-
|
54
|
-
def i18n_domain=(domain)
|
55
|
-
FastGettext.text_domain = domain
|
56
|
-
@i18n_domain = domain
|
57
|
-
end
|
58
|
-
|
59
|
-
def locale
|
60
|
-
@locale
|
61
|
-
end
|
62
|
-
|
63
|
-
def locale=(loc)
|
64
|
-
Isomorfeus.raise_error(message: "Locale #{loc} not available!") unless available_locales.include?(loc)
|
65
|
-
FastGettext.locale = loc
|
66
|
-
@locale = loc
|
67
|
-
end
|
68
|
-
|
69
|
-
def locale_path
|
70
|
-
@locale_path
|
71
|
-
end
|
72
|
-
|
73
|
-
def locale_path=(path)
|
74
|
-
@locale_path = path
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
1
|
+
module Isomorfeus
|
2
|
+
# available settings
|
3
|
+
class << self
|
4
|
+
attr_accessor :i18n_type
|
5
|
+
|
6
|
+
if RUBY_ENGINE == 'opal'
|
7
|
+
def available_locales
|
8
|
+
result = Redux.fetch_by_path(:i18n_state, :available_locales)
|
9
|
+
result ? result : ['en']
|
10
|
+
end
|
11
|
+
|
12
|
+
def i18n_domain
|
13
|
+
result = Redux.fetch_by_path(:i18n_state, :domain)
|
14
|
+
result ? result : 'app'
|
15
|
+
end
|
16
|
+
|
17
|
+
def i18n_domain=(domain)
|
18
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain: domain })
|
19
|
+
domain
|
20
|
+
end
|
21
|
+
|
22
|
+
def locale
|
23
|
+
result = Redux.fetch_by_path(:i18n_state, :locale)
|
24
|
+
result ? result : available_locales.first
|
25
|
+
end
|
26
|
+
|
27
|
+
def locale=(loc)
|
28
|
+
Isomorfeus.raise_error(message: "Locale #{loc} not available!") unless available_locales.include?(loc)
|
29
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { locale: locale })
|
30
|
+
loc
|
31
|
+
end
|
32
|
+
|
33
|
+
def negotiated_locale
|
34
|
+
@negotiated_locale
|
35
|
+
end
|
36
|
+
|
37
|
+
def negotiated_locale=(l)
|
38
|
+
@negotiated_locale = l
|
39
|
+
end
|
40
|
+
else
|
41
|
+
def available_locales
|
42
|
+
@available_locales
|
43
|
+
end
|
44
|
+
|
45
|
+
def available_locales=(locs_arr)
|
46
|
+
FastGettext.available_locales = locs_arr
|
47
|
+
@available_locales = locs_arr
|
48
|
+
end
|
49
|
+
|
50
|
+
def i18n_domain
|
51
|
+
@i18n_domain
|
52
|
+
end
|
53
|
+
|
54
|
+
def i18n_domain=(domain)
|
55
|
+
FastGettext.text_domain = domain
|
56
|
+
@i18n_domain = domain
|
57
|
+
end
|
58
|
+
|
59
|
+
def locale
|
60
|
+
@locale
|
61
|
+
end
|
62
|
+
|
63
|
+
def locale=(loc)
|
64
|
+
Isomorfeus.raise_error(message: "Locale #{loc} not available!") unless available_locales.include?(loc)
|
65
|
+
FastGettext.locale = loc
|
66
|
+
@locale = loc
|
67
|
+
end
|
68
|
+
|
69
|
+
def locale_path
|
70
|
+
@locale_path
|
71
|
+
end
|
72
|
+
|
73
|
+
def locale_path=(path)
|
74
|
+
@locale_path = path
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -1,76 +1,76 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Isomorfeus
|
4
|
-
module I18n
|
5
|
-
module Handler
|
6
|
-
class LocaleHandler < LucidHandler::Base
|
7
|
-
include FastGettext::Translation
|
8
|
-
include FastGettext::TranslationMultidomain
|
9
|
-
|
10
|
-
on_request do |response_agent|
|
11
|
-
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
12
|
-
response_agent.agent_result = {}
|
13
|
-
# promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, method, [args])
|
14
|
-
response_agent.request.each_key do |domain|
|
15
|
-
if domain == 'init'
|
16
|
-
locale = response_agent.request[domain]
|
17
|
-
response_agent.agent_result['data'] = { 'available_locales' => FastGettext.available_locales,
|
18
|
-
'domain' => FastGettext.text_domain }
|
19
|
-
response_agent.agent_result['data']['locale'] = if Isomorfeus.available_locales.include?(locale)
|
20
|
-
locale
|
21
|
-
else
|
22
|
-
FastGettext.locale
|
23
|
-
end
|
24
|
-
else
|
25
|
-
response_agent.agent_result[domain] = {}
|
26
|
-
begin
|
27
|
-
FastGettext.with_domain(domain) do
|
28
|
-
response_agent.request[domain].each_key do |locale|
|
29
|
-
response_agent.agent_result[domain][locale] = {}
|
30
|
-
Isomorfeus.raise_error(message: "Locale #{locale} not available!") unless Isomorfeus.available_locales.include?(locale)
|
31
|
-
FastGettext.with_locale(locale) do
|
32
|
-
response_agent.request[domain][locale].each_key do |locale_method|
|
33
|
-
method_args = response_agent.request[domain][locale][locale_method]
|
34
|
-
method_result = case locale_method
|
35
|
-
when '_' then _(*method_args)
|
36
|
-
when 'n_' then n_(*method_args)
|
37
|
-
when 'np_' then np_(*method_args)
|
38
|
-
when 'ns_' then ns_(*method_args)
|
39
|
-
when 'p_' then p_(*method_args)
|
40
|
-
when 's_' then s_(*method_args)
|
41
|
-
when 'N_' then N_(*method_args)
|
42
|
-
when 'Nn_' then Nn_(*method_args)
|
43
|
-
when 'd_' then d_(*method_args)
|
44
|
-
when 'dn_' then dn_(*method_args)
|
45
|
-
when 'dnp_' then dnp_(*method_args)
|
46
|
-
when 'dns_' then dns_(*method_args)
|
47
|
-
when 'dp_' then dp_(*method_args)
|
48
|
-
when 'ds_' then ds_(*method_args)
|
49
|
-
when 'D_' then D_(*method_args)
|
50
|
-
when 'Dn_' then Dn_(*method_args)
|
51
|
-
when 'Dnp_' then Dnp_(*method_args)
|
52
|
-
when 'Dns_' then Dns_(*method_args)
|
53
|
-
when 'Dp_' then Dp_(*method_args)
|
54
|
-
when 'Ds_' then Ds_(*method_args)
|
55
|
-
else
|
56
|
-
Isomorfeus.raise_error(message: "No such locale method #{locale_method}")
|
57
|
-
end
|
58
|
-
response_agent.agent_result[domain][locale].deep_merge!(locale_method => { Oj.dump(method_args, mode: :strict) => method_result })
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
rescue Exception => e
|
64
|
-
response_agent.error = if Isomorfeus.production?
|
65
|
-
{ error: 'No such thing!' }
|
66
|
-
else
|
67
|
-
{ error: "Isomorfeus::I18n::Handler::LocaleHandler: #{e.message}" }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Isomorfeus
|
4
|
+
module I18n
|
5
|
+
module Handler
|
6
|
+
class LocaleHandler < LucidHandler::Base
|
7
|
+
include FastGettext::Translation
|
8
|
+
include FastGettext::TranslationMultidomain
|
9
|
+
|
10
|
+
on_request do |response_agent|
|
11
|
+
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
12
|
+
response_agent.agent_result = {}
|
13
|
+
# promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, method, [args])
|
14
|
+
response_agent.request.each_key do |domain|
|
15
|
+
if domain == 'init'
|
16
|
+
locale = response_agent.request[domain]
|
17
|
+
response_agent.agent_result['data'] = { 'available_locales' => FastGettext.available_locales,
|
18
|
+
'domain' => FastGettext.text_domain }
|
19
|
+
response_agent.agent_result['data']['locale'] = if Isomorfeus.available_locales.include?(locale)
|
20
|
+
locale
|
21
|
+
else
|
22
|
+
FastGettext.locale
|
23
|
+
end
|
24
|
+
else
|
25
|
+
response_agent.agent_result[domain] = {}
|
26
|
+
begin
|
27
|
+
FastGettext.with_domain(domain) do
|
28
|
+
response_agent.request[domain].each_key do |locale|
|
29
|
+
response_agent.agent_result[domain][locale] = {}
|
30
|
+
Isomorfeus.raise_error(message: "Locale #{locale} not available!") unless Isomorfeus.available_locales.include?(locale)
|
31
|
+
FastGettext.with_locale(locale) do
|
32
|
+
response_agent.request[domain][locale].each_key do |locale_method|
|
33
|
+
method_args = response_agent.request[domain][locale][locale_method]
|
34
|
+
method_result = case locale_method
|
35
|
+
when '_' then _(*method_args)
|
36
|
+
when 'n_' then n_(*method_args)
|
37
|
+
when 'np_' then np_(*method_args)
|
38
|
+
when 'ns_' then ns_(*method_args)
|
39
|
+
when 'p_' then p_(*method_args)
|
40
|
+
when 's_' then s_(*method_args)
|
41
|
+
when 'N_' then N_(*method_args)
|
42
|
+
when 'Nn_' then Nn_(*method_args)
|
43
|
+
when 'd_' then d_(*method_args)
|
44
|
+
when 'dn_' then dn_(*method_args)
|
45
|
+
when 'dnp_' then dnp_(*method_args)
|
46
|
+
when 'dns_' then dns_(*method_args)
|
47
|
+
when 'dp_' then dp_(*method_args)
|
48
|
+
when 'ds_' then ds_(*method_args)
|
49
|
+
when 'D_' then D_(*method_args)
|
50
|
+
when 'Dn_' then Dn_(*method_args)
|
51
|
+
when 'Dnp_' then Dnp_(*method_args)
|
52
|
+
when 'Dns_' then Dns_(*method_args)
|
53
|
+
when 'Dp_' then Dp_(*method_args)
|
54
|
+
when 'Ds_' then Ds_(*method_args)
|
55
|
+
else
|
56
|
+
Isomorfeus.raise_error(message: "No such locale method #{locale_method}")
|
57
|
+
end
|
58
|
+
response_agent.agent_result[domain][locale].deep_merge!(locale_method => { Oj.dump(method_args, mode: :strict) => method_result })
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
rescue Exception => e
|
64
|
+
response_agent.error = if Isomorfeus.production?
|
65
|
+
{ error: 'No such thing!' }
|
66
|
+
else
|
67
|
+
{ error: "Isomorfeus::I18n::Handler::LocaleHandler: #{e.message}" }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/isomorfeus/i18n/init.rb
CHANGED
@@ -1,47 +1,47 @@
|
|
1
|
-
module Isomorfeus
|
2
|
-
module I18n
|
3
|
-
class Init
|
4
|
-
if RUBY_ENGINE == 'opal'
|
5
|
-
def self.init
|
6
|
-
return if @initializing || initialized?
|
7
|
-
@initializing = true
|
8
|
-
if Isomorfeus.on_browser?
|
9
|
-
root_element = `document.querySelector('div[data-iso-root]')`
|
10
|
-
Isomorfeus.negotiated_locale = root_element.JS.getAttribute('data-iso-nloc') if root_element
|
11
|
-
init_from_server
|
12
|
-
else
|
13
|
-
init_from_server
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.init_from_server
|
18
|
-
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', :init, Isomorfeus.negotiated_locale).then do |agent|
|
19
|
-
if agent.processed
|
20
|
-
agent.result
|
21
|
-
else
|
22
|
-
agent.processed = true
|
23
|
-
if agent.response.key?(:error)
|
24
|
-
Isomorfeus.raise_error(message: agent.response[:error])
|
25
|
-
end
|
26
|
-
@initializing = false
|
27
|
-
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: agent.response[:data])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.initialized?
|
33
|
-
result = Redux.fetch_by_path(:i18n_state, :available_locales)
|
34
|
-
result ? true : false
|
35
|
-
end
|
36
|
-
else
|
37
|
-
def self.init
|
38
|
-
FastGettext.add_text_domain(Isomorfeus.i18n_domain, path: Isomorfeus.locale_path, type: Isomorfeus.i18n_type)
|
39
|
-
FastGettext.available_locales = Isomorfeus.available_locales
|
40
|
-
FastGettext.text_domain = Isomorfeus.i18n_domain
|
41
|
-
FastGettext.locale = Isomorfeus.locale
|
42
|
-
Thread.current[:isomorfeus_i18n_initialized] = true
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
1
|
+
module Isomorfeus
|
2
|
+
module I18n
|
3
|
+
class Init
|
4
|
+
if RUBY_ENGINE == 'opal'
|
5
|
+
def self.init
|
6
|
+
return if @initializing || initialized?
|
7
|
+
@initializing = true
|
8
|
+
if Isomorfeus.on_browser?
|
9
|
+
root_element = `document.querySelector('div[data-iso-root]')`
|
10
|
+
Isomorfeus.negotiated_locale = root_element.JS.getAttribute('data-iso-nloc') if root_element
|
11
|
+
init_from_server
|
12
|
+
else
|
13
|
+
init_from_server
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.init_from_server
|
18
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', :init, Isomorfeus.negotiated_locale).then do |agent|
|
19
|
+
if agent.processed
|
20
|
+
agent.result
|
21
|
+
else
|
22
|
+
agent.processed = true
|
23
|
+
if agent.response.key?(:error)
|
24
|
+
Isomorfeus.raise_error(message: agent.response[:error])
|
25
|
+
end
|
26
|
+
@initializing = false
|
27
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: agent.response[:data])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.initialized?
|
33
|
+
result = Redux.fetch_by_path(:i18n_state, :available_locales)
|
34
|
+
result ? true : false
|
35
|
+
end
|
36
|
+
else
|
37
|
+
def self.init
|
38
|
+
FastGettext.add_text_domain(Isomorfeus.i18n_domain, path: Isomorfeus.locale_path, type: Isomorfeus.i18n_type)
|
39
|
+
FastGettext.available_locales = Isomorfeus.available_locales
|
40
|
+
FastGettext.text_domain = Isomorfeus.i18n_domain
|
41
|
+
FastGettext.locale = Isomorfeus.locale
|
42
|
+
Thread.current[:isomorfeus_i18n_initialized] = true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
module Isomorfeus
|
2
|
-
module I18n
|
3
|
-
module Reducer
|
4
|
-
def self.add_reducer_to_store
|
5
|
-
i18n_reducer = Redux.create_reducer do |prev_state, action|
|
6
|
-
action_type = action[:type]
|
7
|
-
if action_type.JS.startsWith('I18N_')
|
8
|
-
case action_type
|
9
|
-
when 'I18N_STATE'
|
10
|
-
if action.key?(:set_state)
|
11
|
-
action[:set_state]
|
12
|
-
else
|
13
|
-
prev_state
|
14
|
-
end
|
15
|
-
when 'I18N_LOAD'
|
16
|
-
new_state = {}.merge!(prev_state)
|
17
|
-
if action.key?(:collected)
|
18
|
-
action[:collected].each do |act|
|
19
|
-
new_state.deep_merge!(act[:data])
|
20
|
-
end
|
21
|
-
else
|
22
|
-
new_state.deep_merge!(action[:data])
|
23
|
-
end
|
24
|
-
new_state
|
25
|
-
else
|
26
|
-
prev_state
|
27
|
-
end
|
28
|
-
else
|
29
|
-
prev_state
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Redux::Store.preloaded_state_merge!(i18n_state: {})
|
34
|
-
Redux::Store.add_reducer(i18n_state: i18n_reducer)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
1
|
+
module Isomorfeus
|
2
|
+
module I18n
|
3
|
+
module Reducer
|
4
|
+
def self.add_reducer_to_store
|
5
|
+
i18n_reducer = Redux.create_reducer do |prev_state, action|
|
6
|
+
action_type = action[:type]
|
7
|
+
if action_type.JS.startsWith('I18N_')
|
8
|
+
case action_type
|
9
|
+
when 'I18N_STATE'
|
10
|
+
if action.key?(:set_state)
|
11
|
+
action[:set_state]
|
12
|
+
else
|
13
|
+
prev_state
|
14
|
+
end
|
15
|
+
when 'I18N_LOAD'
|
16
|
+
new_state = {}.merge!(prev_state)
|
17
|
+
if action.key?(:collected)
|
18
|
+
action[:collected].each do |act|
|
19
|
+
new_state.deep_merge!(act[:data])
|
20
|
+
end
|
21
|
+
else
|
22
|
+
new_state.deep_merge!(action[:data])
|
23
|
+
end
|
24
|
+
new_state
|
25
|
+
else
|
26
|
+
prev_state
|
27
|
+
end
|
28
|
+
else
|
29
|
+
prev_state
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Redux::Store.preloaded_state_merge!(i18n_state: {})
|
34
|
+
Redux::Store.add_reducer(i18n_state: i18n_reducer)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module Isomorfeus
|
2
|
-
module I18n
|
3
|
-
VERSION = '
|
4
|
-
end
|
1
|
+
module Isomorfeus
|
2
|
+
module I18n
|
3
|
+
VERSION = '2.0.0.rc4'
|
4
|
+
end
|
5
5
|
end
|