tr8n_client_sdk 4.0.13 → 4.1.1

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: b0a90e855e9c4184040cbf011e4851370a300f91
4
- data.tar.gz: e02d9241fade07efe751bb18620724372fa91746
3
+ metadata.gz: 4850791243b75d53f64645fe0a095480fe021515
4
+ data.tar.gz: 20ebb98526b90113e2d1212e1cc95667dc171541
5
5
  SHA512:
6
- metadata.gz: 4835d5a4e4dbf4fadcc8f34b5d9f93da8e752d9fc55aad768af5a0cf5628ba6225f6cbceb1449669529da0a45b963f58a5bf63be3f8bb480185b721ac856e86e
7
- data.tar.gz: a01ab98b73a3e0d3b61ce59db612c33631933bd65ba11095dd961181153246b88edd7436e409041b249f93c6a68f3b0404b1a38c73c6cd1a23dd1ca44455bed2
6
+ metadata.gz: 2dffdcd34b1c21ade253668617ae9886a1f9dd4524e9c20145558d2fac3f625e64fe7b050fe7baaf6bef22cf8d59cf35bf422d76a737eafe211c46058dd166c7
7
+ data.tar.gz: 4a81c033df5820c38266e5967cdbbe1bbbf6209642ae75d389355710a46d1f7350c0a7cf570038436696562642d51c72cb0c409365d3d8a43f151842e21a234c
data/README.md CHANGED
@@ -4,60 +4,63 @@
4
4
 
5
5
  Tr8n Client SDK for Ruby on Rails
6
6
  ===================================
7
- [![Build Status](https://travis-ci.org/tr8n/tr8n_rails_clientsdk.png?branch=rails-3.2.x)](https://travis-ci.org/tr8n/tr8n_rails_clientsdk)
7
+ [![Build Status](https://travis-ci.org/tr8n/tr8n_rails_clientsdk.png?branch=master)](https://travis-ci.org/tr8n/tr8n_rails_clientsdk)
8
8
  [![Coverage Status](https://coveralls.io/repos/tr8n/tr8n_rails_clientsdk/badge.png)](https://coveralls.io/r/tr8n/tr8n_rails_clientsdk)
9
9
  [![Gem Version](https://badge.fury.io/rb/tr8n_client_sdk.png)](http://badge.fury.io/rb/tr8n_client_sdk)
10
- [![Dependency Status](https://www.versioneye.com/user/projects/53cda6a5225426f1e8000165/badge.svg?style=flat)](https://www.versioneye.com/user/projects/53cda6a5225426f1e8000165)
10
+ [![Dependency Status](https://www.versioneye.com/user/projects/52e4bc4cec1375b57600000f/badge.png)](https://www.versioneye.com/user/projects/52e4bc4cec1375b57600000f)
11
11
  [![Project status](http://stillmaintained.com/tr8n/tr8n_ruby_core.png)](http://stillmaintained.com/tr8n/tr8n_ruby_core.png)
12
12
 
13
- This Client SDK provides extensions necessary for translating Rails 4.0.X based application using the TranslationExchange.com service.
13
+ This Client SDK provides extensions necessary for translating Rails based application using the Tr8nHub service.
14
14
 
15
15
 
16
16
  Tr8n Client SDK Sample
17
17
  ===================================
18
18
 
19
- The best way to start using the SDK is to run a sample application that comes bundled with this SDK.
19
+ The best way to start using Tr8nHub is to run the sample application that comes bundled with this SDK.
20
20
 
21
21
  ```sh
22
22
  $ git clone https://github.com/tr8n/tr8n_rails_clientsdk.git
23
23
  $ cd tr8n_rails_clientsdk/spec/dummy
24
24
  $ bundle
25
+ $ script/rails s
25
26
  ```
26
27
 
27
- Before you running the application, visit TranslationExchange.com, register as a new user and create a new application.
28
+ This will start the dummy application in development mode. The development mode uses Tr8nHub sandbox server for translations.
28
29
 
29
- Update your key and secret in the following file: config/initializers/tr8n.rb
30
30
 
31
- ```ruby
32
- config.application = {
33
- :key => YOUR_KEY,
34
- :secret => YOUR_SECRET
35
- }
36
- ```
31
+ Alternatively, you can use the same sample application as a stand alone app:
37
32
 
38
- Now you can start the application by running:
33
+ https://github.com/tr8n/tr8n_rails_clientsdk_sample
39
34
 
40
- ```sh
41
- $ bundle exec rails s
42
- ```
35
+ This application is running at:
36
+
37
+ http://rails.tr8nhub.com
38
+
39
+
40
+ Another sample application that uses this SDK is available here:
43
41
 
42
+ https://github.com/tr8n/tr8n_samples_bookface_rails
44
43
 
45
- This will start the dummy application on port 3000. Open your browser and point to:
44
+ Install it and see how it works.
46
45
 
47
- http://localhost:3000
48
46
 
47
+ Registering Your App
48
+ ===================================
49
+
50
+ Before you can proceed with the integration, please register with https://translationexchange.com and create a new application.
49
51
 
52
+ At the end of the registration process you will be given a key and a secret. You will need to enter them in the initialization function of the Tr8n SDK.
50
53
 
51
54
 
52
55
  Integration
53
56
  ===================================
54
57
 
55
- To integrate Tr8n SDK into your own app, all you need to do is:
58
+ To integrate Tr8n SDK into your app, all you need to do is:
56
59
 
57
- Add the following gem to your Gemfile:
60
+ Add the following gems to your Gemfile:
58
61
 
59
62
  ```ruby
60
- gem 'tr8n_client_sdk', '~> 4.0'
63
+ gem 'tr8n_client_sdk'
61
64
  ```
62
65
 
63
66
  Install the gems:
@@ -66,7 +69,7 @@ Install the gems:
66
69
  $ bundle
67
70
  ```
68
71
 
69
- Create an initializer file under config/initializers/tr8n.rb and add the following configuration:
72
+ Add the following configuration to your Application.rb (or to the various environment files):
70
73
 
71
74
  ```ruby
72
75
  Tr8n.configure do |config|
@@ -77,39 +80,6 @@ Create an initializer file under config/initializers/tr8n.rb and add the followi
77
80
  end
78
81
  ```
79
82
 
80
- Tr8n is best run with caching enabled. You can specify your caching adapter using the following settings:
81
-
82
- Memcache example:
83
-
84
- ```ruby
85
- Tr8n.configure do |config|
86
- config.cache = {
87
- :enabled => true,
88
- :adapter => 'memcache',
89
- :host => 'localhost:11211',
90
- :version => 1,
91
- :timeout => 3600
92
- }
93
- end
94
- ```
95
-
96
- Redis example:
97
-
98
- ```ruby
99
- Tr8n.configure do |config|
100
- config.cache = {
101
- :enabled => true,
102
- :adapter => 'redis',
103
- :host => 'localhost:6379',
104
- :version => 1,
105
- :timeout => 3600
106
- }
107
- end
108
- ```
109
-
110
- To see a full list of supported cache adapters or to create your own cache adapter, visit TranslationExchange.com/docs
111
-
112
-
113
83
  In the HEAD section of your layout, add:
114
84
 
115
85
  ```ruby
@@ -133,12 +103,38 @@ And use TML (Translation Markup Language) to translate your strings, using:
133
103
  ...
134
104
  ```
135
105
 
136
- Learn more about TML at: https://TranslationExchange.com/docs
106
+ Learn more about TML at: http://wiki.tr8nhub.com
137
107
 
138
108
 
139
109
  Caching
140
110
  ===================================
141
111
 
112
+ You should enable caching for your application. Without caching you will be querying the service for new translations on every page load.
113
+ If you do it too much, you will be throttled. The translation service is designed to service the up-to-date translations only if you your translators are in translation mode.
114
+ For all other users you should serve translations from your cache.
115
+
116
+ To enable cache, simply add the following configuration to Tr8n config:
117
+
118
+ ```ruby
119
+ Tr8n.configure do |config|
120
+ config.cache = {
121
+ :enabled => true,
122
+ :adapter => 'memcache',
123
+ :host => 'localhost:11211',
124
+ :version => 2,
125
+ :timeout => 3600
126
+ }
127
+ end
128
+ ```
129
+
130
+ The following Cache adapters are supported:
131
+
132
+ Memcache, Redis, CDB, File
133
+
134
+ It is easy to add any other custom cache adapter as well.
135
+
136
+ Memcache and Redis adapters can do a realtime cache warmup - by loading the translations from the service and storing them in the cache.
137
+
142
138
  To reset/upgrade your cache, you can simply call
143
139
 
144
140
  ```ruby
@@ -148,7 +144,13 @@ To reset/upgrade your cache, you can simply call
148
144
  All the keys stored in memory based cache are versioned. By upgrading the version you will effectively invalidate the old keys and the new keys will be loaded from the translation service.
149
145
 
150
146
 
151
- File adapters require pre-generation. You can pre-generate your cache by running:
147
+ CDB and File adapters require pre-generation. You can pre-generate your cache by running:
148
+
149
+ ```sh
150
+ $ rake tr8n:generate_cache:file
151
+ ```
152
+
153
+ or
152
154
 
153
155
  ```sh
154
156
  $ rake tr8n:generate_cache:cdb
@@ -175,7 +177,7 @@ Tr8n comes with its own logger. If you would like to see what the SDK is doing b
175
177
  ```
176
178
 
177
179
 
178
- Customization
180
+ Rules Engine Customizations
179
181
  ===================================
180
182
 
181
183
  Tr8n comes with default settings for the rules engine. For example, it assumes that you have the following methods in your ApplicationController:
@@ -1,53 +1,5 @@
1
- <% if opts[:type] == :dropdown %>
2
- <script>
3
- function tr8n_change_locale(selector) {
4
- var query_parts = window.location.href.split('?');
5
- var query = query_parts.length > 1 ? query_parts[1] : null;
6
- var params = {};
7
- if (query) {
8
- var vars = query.split('&');
9
- for (var i = 0; i < vars.length; i++) {
10
- var pair = vars[i].split('=');
11
- params[pair[0]] = pair[1];
12
- }
13
- }
14
- params['locale'] = selector.options[selector.selectedIndex].value;
15
-
16
- query = [];
17
- var keys = Object.keys(params);
18
- for (var i = 0; i < keys.length; i++) {
19
- query.push(encodeURIComponent(keys[i]) + "=" + encodeURIComponent(params[keys[i]]));
20
- }
21
-
22
- var destination = query_parts[0] + '?' + query.join("&");
23
- window.location = destination;
24
- }
25
- </script>
26
- <select id="tr8n_language_selector" onchange="tr8n_change_locale(this)" style="<%=opts[:style]%>" class="<%=opts[:class]%>">
27
- <% tr8n_application.languages.each do |lang| %>
28
- <option dir='ltr' value="<%=lang.locale%>" <%="selected" if lang.locale == tr8n_current_locale %>>
29
- <% if opts[:language] == :native %>
30
- <%= lang.native_name %>
31
- <% elsif opts[:language] == :english %>
32
- <%= lang.english_name %>
33
- <% else %>
34
- <%= lang.name %>
35
- <% end %>
36
- </option>
37
- <% end %>
38
- </select>
39
- <% else %>
40
- <a href="#" onClick="Tr8n.UI.LanguageSelector.show(); return false;">
41
- <% unless opts[:hide_flag] %>
42
- <%= image_tag(tr8n_current_language.flag_url, :style => "align:middle") %>
43
- &nbsp;
44
- <% end %>
45
- <% if opts[:language] == :native %>
46
- <%= tr8n_current_language.native_name %>
47
- <% elsif opts[:language] == :english %>
48
- <%= tr8n_current_language.english_name %>
49
- <% else %>
50
- <%= tr8n_current_language.name %>
51
- <% end %>
52
- </a>
53
- <% end %>
1
+ <a href="#" onClick="Tr8n.UI.LanguageSelector.show(); return false;">
2
+ <%= image_tag(tr8n_current_language.flag_url, :style => "align:middle") %>
3
+ &nbsp;
4
+ <%= tr8n_current_language.name %>
5
+ </a>
@@ -1,20 +1,20 @@
1
1
  <% if Tr8n.config.enabled? %>
2
2
  <% featured_languages = tr8n_application.featured_languages %>
3
- <% if featured_languages.any? %>
3
+ <% if featured_languages.any? %>
4
4
  <style>
5
- .tr8n_language_strip {text-align:center; color:#777;}
6
- .tr8n_language_strip a {text-decoration:none; color:#777; outline:none; border:0px; font-size:10px;}
7
- .tr8n_language_strip a img {border:0px;}
8
- .tr8n_language_strip a:hover {text-decoration:underline}
5
+ .tr8n_language_strip {text-align:center; color:#777;}
6
+ .tr8n_language_strip a {text-decoration:none; color:#777; outline:none; border:0px; font-size:10px;}
7
+ .tr8n_language_strip a img {border:0px;}
8
+ .tr8n_language_strip a:hover {text-decoration:underline}
9
9
  </style>
10
10
  <div class="tr8n_language_strip" style="font-size:12px;">
11
11
  <% featured_languages.each do |lang| %>
12
- <%= tr8n_language_name_tag(lang, opts) %> &nbsp;
12
+ <%= tr8n_language_name_tag(lang, opts) %> &nbsp;
13
13
  <% end %>
14
-
14
+
15
15
  <% if featured_languages.size > 0 %>
16
- <%=link_to_function("&raquo;".html_safe, "Tr8n.UI.LanguageSelector.show()") %>
17
- <% end %>
16
+ <%=link_to_function("&raquo;".html_safe, "Tr8n.UI.LanguageSelector.show()") %>
17
+ <% end %>
18
18
  </div>
19
19
  <% end %>
20
20
  <% end %>
@@ -1,18 +1,18 @@
1
1
  <% if Tr8n.config.enabled? %>
2
2
 
3
3
  <style type="text/css">
4
- .tr8n_fltr {
4
+ .tr8n_fltr {
5
5
  <%=tr8n_style_attribute_tag('float', 'right')%> !important;
6
- }
7
- .tr8n_fltl {
6
+ }
7
+ .tr8n_fltl {
8
8
  <%=tr8n_style_attribute_tag('float', 'left')%> !important;
9
- }
10
- .tr8n_txtr {
9
+ }
10
+ .tr8n_txtr {
11
11
  <%=tr8n_style_attribute_tag('text-align', 'right')%> !important;
12
- }
13
- .tr8n_txtl {
12
+ }
13
+ .tr8n_txtl {
14
14
  <%=tr8n_style_attribute_tag('text-align', 'left')%> !important;
15
- }
15
+ }
16
16
  </style>
17
17
 
18
18
  <script>
@@ -1,14 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
2
+ # Copyright (c) 2010-2013 Michael Berkovich, tr8nhub.com
3
3
  #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
4
  # Permission is hereby granted, free of charge, to any person obtaining
13
5
  # a copy of this software and associated documentation files (the
14
6
  # "Software"), to deal in the Software without restriction, including
@@ -32,7 +24,7 @@
32
24
  namespace :tr8n_client_sdk do
33
25
 
34
26
  task :init => :environment do
35
-
27
+
36
28
  end
37
29
 
38
30
  task :cache do
@@ -1,14 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
2
+ # Copyright (c) 2014 Michael Berkovich, tr8nhub.com
3
3
  #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
4
  # Permission is hereby granted, free of charge, to any person obtaining
13
5
  # a copy of this software and associated documentation files (the
14
6
  # "Software"), to deal in the Software without restriction, including
@@ -29,11 +21,9 @@
29
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
22
  #++
31
23
 
32
- require "tr8n_core"
33
- require "tr8n_client_sdk/core/string"
34
24
  require "tr8n_client_sdk/railtie"
35
25
  require "tr8n_client_sdk/engine"
36
- require "tr8n/cache_adapters/rails"
26
+ require "tr8n_core"
37
27
 
38
28
  module Tr8nClientSdk
39
29
 
@@ -1,14 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
2
+ # Copyright (c) 2013 Michael Berkovich, tr8nhub.com
3
3
  #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
4
  # Permission is hereby granted, free of charge, to any person obtaining
13
5
  # a copy of this software and associated documentation files (the
14
6
  # "Software"), to deal in the Software without restriction, including
@@ -1,14 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
2
+ # Copyright (c) 2013 Michael Berkovich, tr8nhub.com
3
3
  #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
4
  # Permission is hereby granted, free of charge, to any person obtaining
13
5
  # a copy of this software and associated documentation files (the
14
6
  # "Software"), to deal in the Software without restriction, including
@@ -40,10 +32,10 @@ module Tr8nClientSdk
40
32
  # or
41
33
  # tr(:label => label, :description => "", :tokens => {}, :options => {})
42
34
  ############################################################
43
- def tr(label, description = '', tokens = {}, options = {})
44
- params = Tr8n::Utils.normalize_tr_params(label, description, tokens, options)
45
- return params[:label].html_safe if params[:label].tr8n_translated?
35
+ def tr(label, description = "", tokens = {}, options = {})
36
+ return label.html_safe if label.tr8n_translated?
46
37
 
38
+ params = Tr8n::Utils.normalize_tr_params(label, description, tokens, options)
47
39
  params[:options][:caller] = caller
48
40
 
49
41
  if request
@@ -99,32 +91,20 @@ module Tr8nClientSdk
99
91
  ## Common methods - wrappers
100
92
  ######################################################################
101
93
 
102
- def tr8n_session
103
- Tr8n.session
104
- end
105
-
106
94
  def tr8n_application
107
- tr8n_session.application
95
+ Tr8n.session.application
108
96
  end
109
97
 
110
98
  def tr8n_current_user
111
- tr8n_session.current_user
99
+ Tr8n.session.current_user
112
100
  end
113
101
 
114
102
  def tr8n_current_translator
115
- tr8n_session.current_translator
116
- end
117
-
118
- def tr8n_current_locale
119
- tr8n_session.current_language.locale
103
+ Tr8n.session.current_translator
120
104
  end
121
105
 
122
106
  def tr8n_current_language
123
- tr8n_session.current_language
124
- end
125
-
126
- def tr8n_language_dir
127
- tr8n_current_language.dir
107
+ Tr8n.session.current_language
128
108
  end
129
109
 
130
110
  end
@@ -1,14 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
2
+ # Copyright (c) 2013 Michael Berkovich, tr8nhub.com
3
3
  #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
4
  # Permission is hereby granted, free of charge, to any person obtaining
13
5
  # a copy of this software and associated documentation files (the
14
6
  # "Software"), to deal in the Software without restriction, including
@@ -33,18 +25,10 @@ module Tr8nClientSdk
33
25
  module ActionControllerExtension
34
26
 
35
27
  def self.included(base)
36
- base.send(:include, Tr8nClientSdk::ActionCommonMethods)
37
- base.send(:include, InstanceMethods)
28
+ base.send(:include, Tr8nClientSdk::ActionCommonMethods)
29
+ base.send(:include, InstanceMethods)
38
30
  base.before_filter :tr8n_init_client_sdk
39
31
  base.after_filter :tr8n_reset_client_sdk
40
- if defined? base.rescue_from
41
- base.rescue_from 'Tr8n::Exception' do |e|
42
- Tr8n.logger.error(e)
43
- Tr8n.logger.error(e.backtrace)
44
- Tr8n.session.reset
45
- raise e
46
- end
47
- end
48
32
  end
49
33
 
50
34
  module InstanceMethods
@@ -60,7 +44,7 @@ module Tr8nClientSdk
60
44
  end
61
45
  Tr8n.config.default_locale
62
46
  end
63
-
47
+
64
48
  # Overwrite this method in a controller to assign a custom source for all views
65
49
  def tr8n_source
66
50
  "/#{controller_name}/#{action_name}"
@@ -71,79 +55,63 @@ module Tr8nClientSdk
71
55
  # Overwrite this method in a controller to assign a custom component for all views
72
56
  def tr8n_component
73
57
  nil
74
- end
75
-
76
- def tr8n_cookie_name
77
- "tr8n_#{tr8n_application.key}"
78
- end
79
-
80
- def tr8n_cookie
81
- request.cookies[tr8n_cookie_name]
82
- end
83
-
84
- def tr8n_cookie_params
85
- @tr8n_cookie_params ||= begin
86
- if tr8n_cookie
87
- cookie_params = Tr8n::Utils.decode_and_verify_params(tr8n_cookie, tr8n_application.secret)
88
- Tr8n.logger.info(cookie_params.inspect)
89
- cookie_params
90
- else
91
- {}
92
- end
93
- end
94
- end
95
-
96
- def tr8n_translator_locale
97
- tr8n_cookie_params["locale"]
98
- end
58
+ end
99
59
 
100
60
  def tr8n_init_current_locale
101
61
  self.send(Tr8n.config.current_locale_method) if Tr8n.config.current_locale_method
102
62
  rescue
103
- # fallback onto the cookie params from the service
104
- return tr8n_translator_locale if tr8n_translator_locale
105
-
106
63
  # fallback to the default session based locale implementation
107
64
  # choose the first language from the accepted languages header
108
65
  session[:locale] = tr8n_user_preferred_locale unless session[:locale]
109
66
  session[:locale] = params[:locale] if params[:locale]
110
- session[:locale] || Tr8n.config.default_locale
67
+ session[:locale]
111
68
  end
112
69
 
113
70
  def tr8n_init_current_user
114
71
  self.send(Tr8n.config.current_user_method) if Tr8n.config.current_user_method
115
72
  rescue
116
- nil
117
- end
118
-
119
- def tr8n_init_current_translator
120
- if tr8n_cookie_params["translator"]
121
- Tr8n::Translator.new(tr8n_cookie_params["translator"].merge(:application => tr8n_application))
122
- else
123
- nil
124
- end
73
+ Tr8n.config.default_locale
125
74
  end
126
75
 
127
76
  def tr8n_init_client_sdk
128
77
  return if Tr8n.config.disabled?
129
78
 
79
+ Tr8n.logger.info("Initializing request...")
130
80
  @tr8n_started_at = Time.now
131
81
 
132
82
  Tr8n.session.init
133
83
 
134
- Tr8n.session.current_user = tr8n_init_current_user
135
- Tr8n.session.current_language = tr8n_application.language(tr8n_init_current_locale)
136
- Tr8n.session.current_translator = tr8n_init_current_translator
84
+ translator = nil
85
+
86
+ cookie_name = "tr8n_#{tr8n_application.key}"
87
+ if request.cookies[cookie_name]
88
+ Tr8n.logger.info("Cookie exists:")
89
+ cookie_params = Tr8n::Utils.decode_and_verify_params(request.cookies[cookie_name], tr8n_application.secret)
90
+ Tr8n.logger.info(cookie_params.inspect)
91
+ locale = cookie_params["locale"]
92
+ translator = Tr8n::Translator.new(cookie_params["translator"].merge(:application => tr8n_application)) unless cookie_params["translator"].nil?
93
+ else
94
+ Tr8n.logger.info("Cookie does not exist")
95
+ end
137
96
 
97
+ locale ||= tr8n_init_current_locale || Tr8n.config.default_locale
98
+
99
+ Tr8n.session.current_user = tr8n_init_current_user
100
+ Tr8n.session.current_translator = translator
101
+ Tr8n.session.current_language = tr8n_application.language(locale || tr8n_init_current_locale || Tr8n.config.default_locale)
138
102
  Tr8n.session.current_source = tr8n_source
139
103
  Tr8n.session.current_component = tr8n_component
140
104
  end
141
105
 
142
106
  def tr8n_reset_client_sdk
143
107
  return if Tr8n.config.disabled?
108
+
144
109
  @tr8n_finished_at = Time.now
110
+
111
+ Tr8n.logger.info("Resetting request...")
145
112
  tr8n_application.submit_missing_keys
146
113
  Tr8n.session.reset
114
+
147
115
  Tr8n.logger.info("Request took #{@tr8n_finished_at - @tr8n_started_at} mls") if @tr8n_started_at
148
116
  end
149
117
 
@@ -1,14 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
2
+ # Copyright (c) 2013 Michael Berkovich, tr8nhub.com
3
3
  #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
4
  # Permission is hereby granted, free of charge, to any person obtaining
13
5
  # a copy of this software and associated documentation files (the
14
6
  # "Software"), to deal in the Software without restriction, including
@@ -33,15 +25,6 @@ module Tr8nClientSdk
33
25
  module ActionViewExtension
34
26
  extend ActiveSupport::Concern
35
27
 
36
- def trh(tokens = {}, options = {}, &block)
37
- return '' unless block_given?
38
-
39
- label = capture(&block)
40
-
41
- tokenizer = Tr8n::Tokenizers::Dom.new(tokens, options)
42
- tokenizer.translate(label).html_safe
43
- end
44
-
45
28
  def tr8n_options_for_select(options, selected = nil, description = nil, lang = Tr8n.session.current_language)
46
29
  options_for_select(options.tro(description), selected)
47
30
  end
@@ -58,25 +41,25 @@ module Tr8nClientSdk
58
41
  def tr8n_language_flag_tag(lang = tr8n_current_language, opts = {})
59
42
  return "" unless tr8n_application.feature_enabled?(:language_flags)
60
43
  html = image_tag(lang.flag_url, :style => "vertical-align:middle;", :title => lang.native_name)
61
- html << "&nbsp;".html_safe
44
+ html << "&nbsp;".html_safe
62
45
  html.html_safe
63
46
  end
64
47
 
65
48
  def tr8n_language_name_tag(lang = tr8n_current_language, opts = {})
66
49
  show_flag = opts[:flag].nil? ? true : opts[:flag]
67
50
  name_type = opts[:name].nil? ? :full : opts[:name] # :full, :native, :english, :locale
68
- linked = opts[:linked].nil? ? true : opts[:linked]
51
+ linked = opts[:linked].nil? ? true : opts[:linked]
69
52
 
70
53
  html = "<span style='white-space: nowrap'>"
71
54
  html << tr8n_language_flag_tag(lang, opts) if show_flag
72
55
  html << "<span dir='ltr'>"
73
56
 
74
57
  name = case name_type
75
- when :native then lang.native_name
76
- when :english then lang.english_name
77
- when :locale then lang.locale
78
- else lang.full_name
79
- end
58
+ when :native then lang.native_name
59
+ when :english then lang.english_name
60
+ when :locale then lang.locale
61
+ else lang.full_name
62
+ end
80
63
 
81
64
  html << name
82
65
  html << "</span></span>"
@@ -90,25 +73,25 @@ module Tr8nClientSdk
90
73
 
91
74
  def tr8n_language_strip_tag(opts = {})
92
75
  opts[:flag] = opts[:flag].nil? ? false : opts[:flag]
93
- opts[:name] = opts[:name].nil? ? :native : opts[:name]
94
- opts[:linked] = opts[:linked].nil? ? true : opts[:linked]
95
- opts[:javascript] = opts[:javascript].nil? ? false : opts[:javascript]
76
+ opts[:name] = opts[:name].nil? ? :native : opts[:name]
77
+ opts[:linked] = opts[:linked].nil? ? true : opts[:linked]
78
+ opts[:javascript] = opts[:javascript].nil? ? false : opts[:javascript]
96
79
 
97
- render(:partial => '/tr8n_client_sdk/tags/language_strip', :locals => {:opts => opts})
80
+ render(:partial => '/tr8n_client_sdk/tags/language_strip', :locals => {:opts => opts})
98
81
  end
99
82
 
100
83
  def tr8n_flashes_tag(opts = {})
101
- render(:partial => '/tr8n_client_sdk/tags/flashes', :locals => {:opts => opts})
84
+ render(:partial => '/tr8n_client_sdk/tags/flashes', :locals => {:opts => opts})
102
85
  end
103
86
 
104
87
  def tr8n_scripts_tag(opts = {})
105
- render(:partial => '/tr8n_client_sdk/tags/scripts', :locals => {:opts => opts})
88
+ render(:partial => '/tr8n_client_sdk/tags/scripts', :locals => {:opts => opts})
106
89
  end
107
90
 
108
91
  def tr8n_select_month(date, options = {}, html_options = {})
109
92
  month_names = options[:use_short_month] ? Tr8n.config.default_abbr_month_names : Tr8n.config.default_month_names
110
93
  select_month(date, options.merge(
111
- :use_month_names => month_names.collect{|month_name| tr8n_current_language.translate(month_name, options[:description] || "Month name")}
94
+ :use_month_names => month_names.collect{|month_name| tr8n_current_language.translate(month_name, options[:description] || "Month name")}
112
95
  ), html_options)
113
96
  end
114
97
 
@@ -128,7 +111,6 @@ module Tr8nClientSdk
128
111
  Thread.current[:block_options].pop
129
112
  ret
130
113
  end
131
- alias_method :tr8n_block, :tr8n_with_options_tag
132
114
 
133
115
  def tr8n_when_string_tag(time, opts = {})
134
116
  elapsed_seconds = Time.now - time
@@ -138,12 +120,12 @@ module Tr8nClientSdk
138
120
  tr('a moment ago', 'Time reference')
139
121
  elsif elapsed_seconds < 55.minutes
140
122
  elapsed_minutes = (elapsed_seconds / 1.minute).to_i
141
- tr('{minutes || minute} ago', 'Time reference', :minutes => elapsed_minutes)
123
+ tr("{minutes||minute} ago", 'Time reference', :minutes => elapsed_minutes)
142
124
  elsif elapsed_seconds < 1.75.hours
143
- tr('about an hour ago', 'Time reference')
125
+ tr("about an hour ago", 'Time reference')
144
126
  elsif elapsed_seconds < 12.hours
145
127
  elapsed_hours = (elapsed_seconds / 1.hour).to_i
146
- tr('{hours || hour} ago', 'Time reference', :hours => elapsed_hours)
128
+ tr("{hours||hour} ago", 'Time reference', :hours => elapsed_hours)
147
129
  elsif time.today_in_time_zone?
148
130
  display_time(time, :time_am_pm)
149
131
  elsif time.yesterday_in_time_zone?
@@ -151,39 +133,31 @@ module Tr8nClientSdk
151
133
  elsif elapsed_seconds < 5.days
152
134
  time.tr(:day_time).gsub('/ ', '/').sub(/^[0:]*/,"")
153
135
  elsif time.same_year_in_time_zone?
154
- time.tr(:monthname_abbr_time).gsub('/ ', '/').sub(/^[0:]*/, '')
136
+ time.tr(:monthname_abbr_time).gsub('/ ', '/').sub(/^[0:]*/,"")
155
137
  else
156
- time.tr(:monthname_abbr_year_time).gsub('/ ', '/').sub(/^[0:]*/, '')
138
+ time.tr(:monthname_abbr_year_time).gsub('/ ', '/').sub(/^[0:]*/,"")
157
139
  end
158
140
  end
159
141
 
160
142
  def tr8n_url_tag(path)
161
143
  tr8n_application.url_for(path)
162
144
  end
163
-
145
+
164
146
  ######################################################################
165
147
  ## Language Direction Support
166
148
  ######################################################################
167
149
 
168
150
  def tr8n_style_attribute_tag(attr_name = 'float', default = 'right', lang = tr8n_current_language)
169
- return "#{attr_name}:#{default}".html_safe if Tr8n.config.disabled?
170
151
  "#{attr_name}:#{lang.align(default)}".html_safe
171
152
  end
172
153
 
173
154
  def tr8n_style_directional_attribute_tag(attr_name = 'padding', default = 'right', value = '5px', lang = tr8n_current_language)
174
- return "#{attr_name}-#{default}:#{value}".html_safe if Tr8n.config.disabled?
175
155
  "#{attr_name}-#{lang.align(default)}:#{value}".html_safe
176
156
  end
177
157
 
178
158
  def tr8n_dir_attribute_tag(lang = tr8n_current_language)
179
- return "dir='ltr'" if Tr8n.config.disabled?
180
159
  "dir='#{lang.dir}'".html_safe
181
160
  end
182
161
 
183
- def tr8n_lang_attribute_tag(lang = tr8n_current_language)
184
- return "lang='en-US'" if Tr8n.config.disabled?
185
- "lang='#{lang.locale}'".html_safe
186
- end
187
-
188
162
  end
189
163
  end
@@ -1,14 +1,6 @@
1
1
  #--
2
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
2
+ # Copyright (c) 2014 Michael Berkovich, tr8nhub.com
3
3
  #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
4
  # Permission is hereby granted, free of charge, to any person obtaining
13
5
  # a copy of this software and associated documentation files (the
14
6
  # "Software"), to deal in the Software without restriction, including
@@ -46,7 +38,7 @@ module Tr8nClientSdk
46
38
  end
47
39
  ActiveSupport.on_load(:action_controller) do
48
40
  include Tr8nClientSdk::ActionControllerExtension
49
- end
41
+ end
50
42
  end
51
43
  end
52
44
  end
@@ -23,5 +23,5 @@
23
23
 
24
24
 
25
25
  module Tr8nClientSdk
26
- VERSION = '4.0.13'
26
+ VERSION = "4.1.1"
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tr8n_client_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.13
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Berkovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: 4.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: 4.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tr8n_core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: 4.0.6
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: 4.0.6
41
41
  description: Client SDK for Tr8n translation engine.
42
42
  email:
43
43
  - michael@tr8nhub.com
@@ -45,24 +45,22 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - LICENSE
49
- - README.md
50
- - Rakefile
51
48
  - app/views/tr8n_client_sdk/tags/_language_selector.html.erb
52
49
  - app/views/tr8n_client_sdk/tags/_language_strip.html.erb
53
50
  - app/views/tr8n_client_sdk/tags/_powered_by_tr8n.html.erb
54
51
  - app/views/tr8n_client_sdk/tags/_scripts.html.erb
55
52
  - config/routes.rb
56
53
  - lib/tasks/tr8n_client_sdk.rake
57
- - lib/tr8n/cache_adapters/rails.rb
58
- - lib/tr8n_client_sdk.rb
59
- - lib/tr8n_client_sdk/core/string.rb
60
54
  - lib/tr8n_client_sdk/engine.rb
61
55
  - lib/tr8n_client_sdk/extensions/action_common_methods.rb
62
56
  - lib/tr8n_client_sdk/extensions/action_controller_extension.rb
63
57
  - lib/tr8n_client_sdk/extensions/action_view_extension.rb
64
58
  - lib/tr8n_client_sdk/railtie.rb
65
59
  - lib/tr8n_client_sdk/version.rb
60
+ - lib/tr8n_client_sdk.rb
61
+ - LICENSE
62
+ - Rakefile
63
+ - README.md
66
64
  homepage: https://github.com/tr8n/tr8n_rails_clientsdk
67
65
  licenses:
68
66
  - MIT-LICENSE
@@ -83,9 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
81
  version: '0'
84
82
  requirements: []
85
83
  rubyforge_project:
86
- rubygems_version: 2.4.1
84
+ rubygems_version: 2.0.3
87
85
  signing_key:
88
86
  specification_version: 4
89
87
  summary: Tr8n Client SDK for Ruby on Rails
90
88
  test_files: []
91
- has_rdoc:
@@ -1,100 +0,0 @@
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
@@ -1,44 +0,0 @@
1
- #--
2
- # Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
3
- #
4
- # _______ _ _ _ ______ _
5
- # |__ __| | | | | (_) | ____| | |
6
- # | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
7
- # | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
8
- # | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
9
- # |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
10
- # __/ |
11
- # |___/
12
- # Permission is hereby granted, free of charge, to any person obtaining
13
- # a copy of this software and associated documentation files (the
14
- # "Software"), to deal in the Software without restriction, including
15
- # without limitation the rights to use, copy, modify, merge, publish,
16
- # distribute, sublicense, and/or sell copies of the Software, and to
17
- # permit persons to whom the Software is furnished to do so, subject to
18
- # the following conditions:
19
- #
20
- # The above copyright notice and this permission notice shall be
21
- # included in all copies or substantial portions of the Software.
22
- #
23
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
- #++
31
-
32
- class String
33
-
34
- def tr8n_translated
35
- return self if frozen?
36
- @tr8n_translated = true
37
- self.html_safe
38
- end
39
-
40
- def tr8n_translated?
41
- @tr8n_translated
42
- end
43
-
44
- end