isomorfeus-i18n 1.0.0.delta11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/lib/isomorfeus/i18n/config.rb +71 -0
- data/lib/isomorfeus/i18n/handler/locale_handler.rb +70 -0
- data/lib/isomorfeus/i18n/init.rb +33 -0
- data/lib/isomorfeus/i18n/reducer.rb +31 -0
- data/lib/isomorfeus/i18n/version.rb +5 -0
- data/lib/isomorfeus-i18n.rb +66 -0
- data/lib/lucid_translation/mixin.rb +232 -0
- metadata +190 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 517b69898ba863abe013e1d04288970a6d398137ab4b39b7ef8a8b604ffffeb8
|
4
|
+
data.tar.gz: 7d9afaa9e3ec79ff07e6c76c921024ce79e521b0d947f05f9c5219675e466e60
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0fad88f98f0c80b712301e0ade3bc72cb8de6496cd7fc0451b1acd715e92fa55f3c07a82ce2c7eb0e6a76645faeac2b2b4fa2f61f5d63bdad39fd83a4bd582ac
|
7
|
+
data.tar.gz: 5bdb60a2804cee36df9ead50fa1081efc2ee709334619ac7a848a6e3bd4f006f29ba310e87a80f7fc26a34c8a05bcc36d08d051ff7f497018eb77a7b822819d1
|
data/LICENSE
ADDED
@@ -0,0 +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.
|
@@ -0,0 +1,71 @@
|
|
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.register_and_fetch_by_path(:i18n_state, :available_locales)
|
9
|
+
result ? result : ['en']
|
10
|
+
end
|
11
|
+
|
12
|
+
def i18n_domain
|
13
|
+
result = Redux.register_and_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.register_and_fetch_by_path(:i18n_state, :locale)
|
24
|
+
result ? result : available_locales.first
|
25
|
+
end
|
26
|
+
|
27
|
+
def locale=(loc)
|
28
|
+
raise "Locale #{loc} not available!" unless available_locales.include?(loc)
|
29
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { locale: locale })
|
30
|
+
loc
|
31
|
+
end
|
32
|
+
else
|
33
|
+
def available_locales
|
34
|
+
@available_locales
|
35
|
+
end
|
36
|
+
|
37
|
+
def available_locales=(locs_arr)
|
38
|
+
FastGettext.available_locales = locs_arr
|
39
|
+
@available_locales = locs_arr
|
40
|
+
end
|
41
|
+
|
42
|
+
def i18n_domain
|
43
|
+
@i18n_domain
|
44
|
+
end
|
45
|
+
|
46
|
+
def i18n_domain=(domain)
|
47
|
+
FastGettext.text_domain = domain
|
48
|
+
@i18n_domain = domain
|
49
|
+
end
|
50
|
+
|
51
|
+
def locale
|
52
|
+
@locale
|
53
|
+
end
|
54
|
+
|
55
|
+
def locale=(loc)
|
56
|
+
raise "Locale #{loc} not available!" unless available_locales.include?(loc)
|
57
|
+
FastGettext.locale = loc
|
58
|
+
@locale = loc
|
59
|
+
end
|
60
|
+
|
61
|
+
def locale_path
|
62
|
+
@locale_path
|
63
|
+
end
|
64
|
+
|
65
|
+
def locale_path=(path)
|
66
|
+
@locale_path = path
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module I18n
|
3
|
+
module Handler
|
4
|
+
class LocaleHandler < LucidHandler::Base
|
5
|
+
include FastGettext::Translation
|
6
|
+
include FastGettext::TranslationMultidomain
|
7
|
+
|
8
|
+
on_request do |pub_sub_client, session_id, current_user, request, response|
|
9
|
+
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
10
|
+
result = {}
|
11
|
+
# promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, method, [args])
|
12
|
+
if request == 'init'
|
13
|
+
result['data'] = { 'available_locales' => FastGettext.available_locales,
|
14
|
+
'locale' => FastGettext.locale,
|
15
|
+
'domain' => FastGettext.text_domain }
|
16
|
+
else
|
17
|
+
request.each_key do |domain|
|
18
|
+
result[domain] = {}
|
19
|
+
begin
|
20
|
+
FastGettext.with_domain(domain) do
|
21
|
+
request[domain].each_key do |locale|
|
22
|
+
result[domain][locale] = {}
|
23
|
+
raise "Locale #{locale} not available!" unless Isomorfeus.available_locales.include?(locale)
|
24
|
+
FastGettext.with_locale(locale) do
|
25
|
+
request[domain][locale].each_key do |locale_method|
|
26
|
+
method_args = request[domain][locale][locale_method]
|
27
|
+
method_result = case locale_method
|
28
|
+
when '_' then _(*method_args)
|
29
|
+
when 'n_' then n_(*method_args)
|
30
|
+
when 'np_' then np_(*method_args)
|
31
|
+
when 'ns_' then ns_(*method_args)
|
32
|
+
when 'p_' then p_(*method_args)
|
33
|
+
when 's_' then s_(*method_args)
|
34
|
+
when 'N_' then N_(*method_args)
|
35
|
+
when 'Nn_' then Nn_(*method_args)
|
36
|
+
when 'd_' then d_(*method_args)
|
37
|
+
when 'dn_' then dn_(*method_args)
|
38
|
+
when 'dnp_' then dnp_(*method_args)
|
39
|
+
when 'dns_' then dns_(*method_args)
|
40
|
+
when 'dp_' then dp_(*method_args)
|
41
|
+
when 'ds_' then ds_(*method_args)
|
42
|
+
when 'D_' then D_(*method_args)
|
43
|
+
when 'Dn_' then Dn_(*method_args)
|
44
|
+
when 'Dnp_' then Dnp_(*method_args)
|
45
|
+
when 'Dns_' then Dns_(*method_args)
|
46
|
+
when 'Dp_' then Dp_(*method_args)
|
47
|
+
when 'Ds_' then Ds_(*method_args)
|
48
|
+
else
|
49
|
+
raise "No such locale method #{locale_method}"
|
50
|
+
end
|
51
|
+
result[domain][locale].deep_merge!(locale_method => { Oj.dump(method_args, mode: :strict) => method_result })
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
rescue Exception => e
|
57
|
+
result = if Isomorfeus.production?
|
58
|
+
{ error: 'No such thing!' }
|
59
|
+
else
|
60
|
+
{ error: "Isomorfeus::I18n::Handler::LocaleHandler: #{e.message}" }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
result
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', :init).then do |response|
|
9
|
+
if response[:agent_response].key?(:error)
|
10
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
11
|
+
raise response[:agent_response][:error]
|
12
|
+
end
|
13
|
+
@initializing = false
|
14
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: response[:agent_response][:data])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.initialized?
|
19
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, :available_locales)
|
20
|
+
result ? true : false
|
21
|
+
end
|
22
|
+
else
|
23
|
+
def self.init
|
24
|
+
FastGettext.add_text_domain(Isomorfeus.i18n_domain, path: Isomorfeus.locale_path, type: Isomorfeus.i18n_type)
|
25
|
+
FastGettext.available_locales = Isomorfeus.available_locales
|
26
|
+
FastGettext.text_domain = Isomorfeus.i18n_domain
|
27
|
+
FastGettext.locale = Isomorfeus.locale
|
28
|
+
Thread.current[:isomorfeus_i18n_initialized] = true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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
|
+
result = prev_state.deep_merge(action[:data])
|
17
|
+
result
|
18
|
+
else
|
19
|
+
prev_state
|
20
|
+
end
|
21
|
+
else
|
22
|
+
prev_state
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Redux::Store.preloaded_state_merge!(i18n_state: {})
|
27
|
+
Redux::Store.add_reducer(i18n_state: i18n_reducer)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'opal-activesupport'
|
2
|
+
require 'isomorfeus-transport'
|
3
|
+
|
4
|
+
if RUBY_ENGINE == 'opal'
|
5
|
+
require 'isomorfeus/data/core_ext/hash/deep_merge'
|
6
|
+
require 'isomorfeus/i18n/config'
|
7
|
+
require 'isomorfeus/i18n/reducer'
|
8
|
+
Isomorfeus::I18n::Reducer.add_reducer_to_store
|
9
|
+
require 'lucid_translation/mixin'
|
10
|
+
require 'isomorfeus/i18n/init'
|
11
|
+
Isomorfeus.add_transport_init_class_name('Isomorfeus::I18n::Init')
|
12
|
+
else
|
13
|
+
require 'active_support'
|
14
|
+
require 'oj'
|
15
|
+
require 'fast_gettext'
|
16
|
+
require 'isomorfeus/promise'
|
17
|
+
require 'isomorfeus-data'
|
18
|
+
require 'isomorfeus/i18n/config'
|
19
|
+
require 'isomorfeus/i18n/init'
|
20
|
+
require 'lucid_translation/mixin'
|
21
|
+
require 'isomorfeus/i18n/handler/locale_handler'
|
22
|
+
|
23
|
+
Opal.append_path(__dir__.untaint) unless Opal.paths.include?(__dir__.untaint)
|
24
|
+
|
25
|
+
Isomorfeus.locale_path = File.expand_path(File.join('isomorfeus', 'locales'))
|
26
|
+
|
27
|
+
# identify available locales
|
28
|
+
locales = []
|
29
|
+
|
30
|
+
Dir.glob("#{Isomorfeus.locale_path}/**/*.mo").each do |file|
|
31
|
+
locales << File.basename(file, '.mo')
|
32
|
+
end
|
33
|
+
Isomorfeus.i18n_type = :mo unless locales.empty?
|
34
|
+
|
35
|
+
unless Isomorfeus.i18n_type
|
36
|
+
locales = []
|
37
|
+
Dir.glob("#{Isomorfeus.locale_path}/**/*.po").each do |file|
|
38
|
+
locales << File.basename(file, '.po')
|
39
|
+
end
|
40
|
+
Isomorfeus.i18n_type = :po unless locales.empty?
|
41
|
+
end
|
42
|
+
|
43
|
+
unless Isomorfeus.i18n_type
|
44
|
+
locales = []
|
45
|
+
Dir.glob("#{Isomorfeus.locale_path}/**/*.yaml").each do |file|
|
46
|
+
locales << File.basename(file, '.yaml')
|
47
|
+
end
|
48
|
+
Dir.glob("#{Isomorfeus.locale_path}/**/*.yml").each do |file|
|
49
|
+
locales << File.basename(file, '.yml')
|
50
|
+
end
|
51
|
+
Isomorfeus.i18n_type = :yaml unless locales.empty?
|
52
|
+
end
|
53
|
+
|
54
|
+
Isomorfeus.available_locales = locales
|
55
|
+
Isomorfeus.available_locales = ['en'] if Isomorfeus.available_locales.empty?
|
56
|
+
|
57
|
+
if Isomorfeus.available_locales.include?('en')
|
58
|
+
Isomorfeus.locale = 'en'
|
59
|
+
else
|
60
|
+
Isomorfeus.locale = Isomorfeus.available_locales.first
|
61
|
+
end
|
62
|
+
|
63
|
+
Isomorfeus.i18n_domain = 'app'
|
64
|
+
|
65
|
+
Isomorfeus::I18n::Init.init
|
66
|
+
end
|
@@ -0,0 +1,232 @@
|
|
1
|
+
module LucidTranslation
|
2
|
+
module Mixin
|
3
|
+
CONTEXT_SEPARATOR = "\004"
|
4
|
+
NAMESPACE_SEPARATOR = '|'
|
5
|
+
NIL_BLOCK = -> { nil }
|
6
|
+
TRANSLATION_METHODS = [:_, :n_, :np_, :ns_, :p_, :s_]
|
7
|
+
|
8
|
+
if RUBY_ENGINE != 'opal'
|
9
|
+
class InternalTranslationProxy
|
10
|
+
extend FastGettext::Translation
|
11
|
+
extend FastGettext::TranslationMultidomain
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.included(base)
|
16
|
+
if RUBY_ENGINE == 'opal'
|
17
|
+
base.instance_exec do
|
18
|
+
def _(*keys, &block)
|
19
|
+
domain = Isomorfeus.i18n_domain
|
20
|
+
locale = Isomorfeus.locale
|
21
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, '_', keys)
|
22
|
+
return result if result
|
23
|
+
if Isomorfeus::I18n::Init.initialized?
|
24
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, '_', keys).then do |response|
|
25
|
+
if response[:agent_response].key?(:error)
|
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
|
31
|
+
end
|
32
|
+
block_given? ? block.call : keys.first
|
33
|
+
end
|
34
|
+
|
35
|
+
def n_(*keys, count, &block)
|
36
|
+
domain = Isomorfeus.i18n_domain
|
37
|
+
locale = Isomorfeus.locale
|
38
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, 'n_', keys + [count])
|
39
|
+
return result if result
|
40
|
+
if Isomorfeus::I18n::Init.initialized?
|
41
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, 'n_', keys + [count]).then do |response|
|
42
|
+
if response[:agent_response].key?(:error)
|
43
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
44
|
+
raise response[:agent_response][:error]
|
45
|
+
end
|
46
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
47
|
+
end
|
48
|
+
end
|
49
|
+
block_given? ? block.call : keys.last
|
50
|
+
end
|
51
|
+
|
52
|
+
def np_(context, plural_one, *args, separator: nil, &block)
|
53
|
+
nargs = ["#{context}#{separator || CONTEXT_SEPARATOR}#{plural_one}"] + args
|
54
|
+
translation = n_(*nargs, &NIL_BLOCK)
|
55
|
+
return translation if translation
|
56
|
+
|
57
|
+
block_given? ? block.call : n_(plural_one, *args)
|
58
|
+
end
|
59
|
+
|
60
|
+
def ns_(*args, &block)
|
61
|
+
domain = Isomorfeus.i18n_domain
|
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
|
76
|
+
|
77
|
+
def p_(namespace, key, separator = nil, &block)
|
78
|
+
domain = Isomorfeus.i18n_domain
|
79
|
+
locale = Isomorfeus.locale
|
80
|
+
args = separator ? [namespace, key, separator] : [namespace, key]
|
81
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, 'p_', args)
|
82
|
+
return result if result
|
83
|
+
if Isomorfeus::I18n::Init.initialized?
|
84
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, 'p_', args).then do |response|
|
85
|
+
if response[:agent_response].key?(:error)
|
86
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
87
|
+
raise response[:agent_response][:error]
|
88
|
+
end
|
89
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
90
|
+
end
|
91
|
+
end
|
92
|
+
block_given? ? block.call : key
|
93
|
+
end
|
94
|
+
|
95
|
+
def s_(key, separator = nil, &block)
|
96
|
+
domain = Isomorfeus.i18n_domain
|
97
|
+
locale = Isomorfeus.locale
|
98
|
+
args = separator ? [key, separator] : [key]
|
99
|
+
result = Redux.register_and_fetch_by_path(:i18n_state, domain, locale, 's_', args)
|
100
|
+
return result if result
|
101
|
+
if Isomorfeus::I18n::Init.initialized?
|
102
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::I18n::Handler::LocaleHandler', domain, locale, 's_', args).then do |response|
|
103
|
+
if response[:agent_response].key?(:error)
|
104
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
105
|
+
raise response[:agent_response][:error]
|
106
|
+
end
|
107
|
+
Isomorfeus.store.dispatch(type: 'I18N_LOAD', data: { domain => response[:agent_response][domain] })
|
108
|
+
end
|
109
|
+
end
|
110
|
+
block_given? ? block.call : key.split(separator || NAMESPACE_SEPARATOR).last
|
111
|
+
end
|
112
|
+
|
113
|
+
def N_(translate)
|
114
|
+
translate
|
115
|
+
end
|
116
|
+
|
117
|
+
def Nn_(*keys)
|
118
|
+
keys
|
119
|
+
end
|
120
|
+
|
121
|
+
TRANSLATION_METHODS.each do |method|
|
122
|
+
define_singleton_method("d#{method}") do |domain, *args, &block|
|
123
|
+
old_domain = Isomorfeus.i18n_domain
|
124
|
+
begin
|
125
|
+
Isomorfeus.i18n_domain = domain
|
126
|
+
send(method, *args, &block)
|
127
|
+
ensure
|
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)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def _(*args, &block)
|
152
|
+
self.class._(*args, &block)
|
153
|
+
end
|
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
|
182
|
+
|
183
|
+
TRANSLATION_METHODS.each do |method|
|
184
|
+
# translate in given domain
|
185
|
+
define_method("d#{method}") do |domain, *args, &block|
|
186
|
+
self.class.send("d#{method}", domain, *args, &block)
|
187
|
+
end
|
188
|
+
|
189
|
+
define_method("D#{method}") do |*args, &block|
|
190
|
+
self.class.send("D#{method}", *args, &block)
|
191
|
+
end
|
192
|
+
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
|
+
|
201
|
+
define_singleton_method("d#{method}") do |domain, *args, &block|
|
202
|
+
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
203
|
+
InternalTranslationProxy.send("d#{method}", domain, *args, &block)
|
204
|
+
end
|
205
|
+
|
206
|
+
define_singleton_method("D#{method}") do |*args, &block|
|
207
|
+
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
208
|
+
InternalTranslationProxy.send.send("D#{method}", *args, &block)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
TRANSLATION_METHODS.each do |method|
|
214
|
+
define_method(method) do |domain, *args, &block|
|
215
|
+
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
216
|
+
InternalTranslationProxy.send(method, domain, *args, &block)
|
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
|
223
|
+
|
224
|
+
define_method("D#{method}") do |*args, &block|
|
225
|
+
Isomorfeus::I18n::Init.init unless Thread.current[:isomorfeus_i18n_initialized] == true
|
226
|
+
InternalTranslationProxy.send("D#{method}", *args, &block)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
metadata
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: isomorfeus-i18n
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.delta11
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Biedermann
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fast_gettext
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.0.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: oj
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.8.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: opal
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.11.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.11.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: opal-activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.3.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.3.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: opal-autoloader
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: isomorfeus-react
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 16.9.2
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 16.9.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: isomorfeus-redux
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 4.0.11
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 4.0.11
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: isomorfeus-transport
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.0.0.delta11
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.0.0.delta11
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: isomorfeus-data
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.0.0.delta11
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.0.0.delta11
|
153
|
+
description: I18n for Isomorfeus.
|
154
|
+
email: jan@kursator.de
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- LICENSE
|
160
|
+
- lib/isomorfeus-i18n.rb
|
161
|
+
- lib/isomorfeus/i18n/config.rb
|
162
|
+
- lib/isomorfeus/i18n/handler/locale_handler.rb
|
163
|
+
- lib/isomorfeus/i18n/init.rb
|
164
|
+
- lib/isomorfeus/i18n/reducer.rb
|
165
|
+
- lib/isomorfeus/i18n/version.rb
|
166
|
+
- lib/lucid_translation/mixin.rb
|
167
|
+
homepage: http://isomorfeus.com
|
168
|
+
licenses:
|
169
|
+
- MIT
|
170
|
+
metadata: {}
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - ">"
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: 1.3.1
|
185
|
+
requirements: []
|
186
|
+
rubygems_version: 3.0.3
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: I18n for Isomorfeus.
|
190
|
+
test_files: []
|