tr8n_client_sdk 3.2.3 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a430fd6d3363d71807fa76e4714576232ab7e700
|
4
|
+
data.tar.gz: c8cde0b647c66310f119bb533deb7aa375549651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4764c1074158103a77c61f2a8d157fd5a12a53e80b86446b98d0b7d5ef96dd864f3e9e60dd2ebb969c1b3d6f8a06a4a5713ab59a3a055fbfd614d03b8727951
|
7
|
+
data.tar.gz: e0dd79cbf38762b3d20500c142c6a5ac71133f992aecd6fec02bb37bc12fc0f69e0646b9014013d5e56d54d923c5b58fccf93fcc766669005c1566d4c12b0701
|
@@ -25,11 +25,11 @@
|
|
25
25
|
</script>
|
26
26
|
<select id="tr8n_language_selector" onchange="tr8n_change_locale(this)" style="<%=opts[:style]%>" class="<%=opts[:class]%>">
|
27
27
|
<% tr8n_application.languages.each do |lang| %>
|
28
|
-
<option value="<%=lang.locale%>" <%="selected" if lang.locale == tr8n_current_locale %>>
|
28
|
+
<option dir='ltr' value="<%=lang.locale%>" <%="selected" if lang.locale == tr8n_current_locale %>>
|
29
29
|
<% if opts[:language] == :native %>
|
30
30
|
<%= lang.native_name %>
|
31
31
|
<% elsif opts[:language] == :english %>
|
32
|
-
|
32
|
+
<%= lang.english_name %>
|
33
33
|
<% else %>
|
34
34
|
<%= lang.name %>
|
35
35
|
<% end %>
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#--
|
3
|
+
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
4
|
+
#
|
5
|
+
# _______ _ _ _ ______ _
|
6
|
+
# |__ __| | | | | (_) | ____| | |
|
7
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
8
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
9
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
10
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
11
|
+
# __/ |
|
12
|
+
# |___/
|
13
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
# a copy of this software and associated documentation files (the
|
15
|
+
# "Software"), to deal in the Software without restriction, including
|
16
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
# the following conditions:
|
20
|
+
#
|
21
|
+
# The above copyright notice and this permission notice shall be
|
22
|
+
# included in all copies or substantial portions of the Software.
|
23
|
+
#
|
24
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
27
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
28
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
29
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
30
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
#++
|
32
|
+
|
33
|
+
require 'dalli' if defined?(Dalli)
|
34
|
+
|
35
|
+
class Tr8n::CacheAdapters::Rails < Tr8n::Cache
|
36
|
+
|
37
|
+
def initialize
|
38
|
+
Tr8n.logger.info("Initializing Rails cache...")
|
39
|
+
@cache = Rails.cache
|
40
|
+
end
|
41
|
+
|
42
|
+
def cache_name
|
43
|
+
@cache.class.name
|
44
|
+
end
|
45
|
+
|
46
|
+
def read_only?
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
50
|
+
def fetch(key, opts = {})
|
51
|
+
miss = false
|
52
|
+
data = @cache.fetch(versioned_key(key, opts)) do
|
53
|
+
info("Cache miss: #{key}")
|
54
|
+
miss = true
|
55
|
+
if block_given?
|
56
|
+
yield
|
57
|
+
else
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
info("Cache hit: #{key}") unless miss
|
62
|
+
data
|
63
|
+
rescue Exception => ex
|
64
|
+
warn("Failed to retrieve data: #{ex.message}")
|
65
|
+
return nil unless block_given?
|
66
|
+
yield
|
67
|
+
end
|
68
|
+
|
69
|
+
def store(key, data, opts = {})
|
70
|
+
info("Cache store: #{key}")
|
71
|
+
@cache.write(versioned_key(key, opts), data)
|
72
|
+
data
|
73
|
+
rescue Exception => ex
|
74
|
+
warn("Failed to store data: #{ex.message}")
|
75
|
+
key
|
76
|
+
end
|
77
|
+
|
78
|
+
def delete(key, opts = {})
|
79
|
+
info("Cache delete: #{key}")
|
80
|
+
@cache.delete(versioned_key(key, opts))
|
81
|
+
key
|
82
|
+
rescue Exception => ex
|
83
|
+
warn("Failed to delete data: #{ex.message}")
|
84
|
+
key
|
85
|
+
end
|
86
|
+
|
87
|
+
def exist?(key, opts = {})
|
88
|
+
data = @cache.fetch(versioned_key(key, opts))
|
89
|
+
not data.nil?
|
90
|
+
rescue Exception => ex
|
91
|
+
warn("Failed to check if key exists: #{ex.message}")
|
92
|
+
false
|
93
|
+
end
|
94
|
+
|
95
|
+
def clear(opts = {})
|
96
|
+
info("Cache clear")
|
97
|
+
rescue Exception => ex
|
98
|
+
warn("Failed to clear cache: #{ex.message}")
|
99
|
+
end
|
100
|
+
end
|
data/lib/tr8n_client_sdk.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tr8n_client_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Berkovich
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- app/views/tr8n_client_sdk/tags/_scripts.html.erb
|
55
55
|
- config/routes.rb
|
56
56
|
- lib/tasks/tr8n_client_sdk.rake
|
57
|
+
- lib/tr8n/cache_adapters/rails.rb
|
57
58
|
- lib/tr8n_client_sdk.rb
|
58
59
|
- lib/tr8n_client_sdk/engine.rb
|
59
60
|
- lib/tr8n_client_sdk/extensions/action_common_methods.rb
|