tr8n_client_sdk 3.3.1 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +89 -246
- data/Rakefile +16 -31
- data/app/views/tr8n_client_sdk/tags/_language_selector.html.erb +5 -53
- data/app/views/tr8n_client_sdk/tags/_language_strip.html.erb +7 -7
- data/app/views/tr8n_client_sdk/tags/_powered_by_tr8n.html.erb +3 -15
- data/app/views/tr8n_client_sdk/tags/_scripts.html.erb +91 -33
- data/config/routes.rb +1 -33
- data/lib/{tr8n_client_sdk/core/string.rb → tasks/tr8n_client_sdk.rake} +12 -17
- data/lib/tr8n_client_sdk/engine.rb +1 -9
- data/lib/tr8n_client_sdk/extensions/action_common_methods.rb +18 -39
- data/lib/tr8n_client_sdk/extensions/action_controller_extension.rb +32 -63
- data/lib/tr8n_client_sdk/extensions/action_view_extension.rb +18 -48
- data/lib/tr8n_client_sdk/railtie.rb +2 -10
- data/lib/tr8n_client_sdk/version.rb +3 -10
- data/lib/tr8n_client_sdk.rb +2 -13
- metadata +15 -20
- data/app/controllers/tr8n_client_sdk/cache_controller.rb +0 -39
- data/lib/i18n/backend/tr8n.rb +0 -62
- data/lib/tasks/tr8n.rake +0 -60
- data/lib/tr8n/cache_adapters/rails.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7f8925013525f8938a75594e1d5eb16c02c5acd
|
4
|
+
data.tar.gz: 0886a469ae942bafc104d47a171616c0d80b38c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dd77ef8619a5962632926515074a37ef26c31452f7c2301683fc9e70891f5623271ffae9419cbcade8852a896b9318d1c284714bf5d647ad368a3902b3d7f7d
|
7
|
+
data.tar.gz: a41ab827d15eb401d369e85901f6bd77ef19d2d53f42c568f40a0ea5deb86987cd47358c6dc58a3fc06a38c9254bc8726303eda24842e04e084e90afe4c0b132
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -2,239 +2,147 @@
|
|
2
2
|
<img src="https://raw.github.com/tr8n/tr8n/master/doc/screenshots/tr8nlogo.png">
|
3
3
|
</p>
|
4
4
|
|
5
|
-
Tr8n SDK for Ruby on Rails
|
5
|
+
Tr8n Client SDK for Ruby on Rails
|
6
6
|
===================================
|
7
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/
|
10
|
+
[![Dependency Status](https://www.versioneye.com/user/projects/52e4bc4cec1375b57600000f/badge.png)](https://www.versioneye.com/user/projects/52e4bc4cec1375b57600000f)
|
11
|
+
[![Project status](http://stillmaintained.com/tr8n/tr8n_ruby_core.png)](http://stillmaintained.com/tr8n/tr8n_ruby_core.png)
|
11
12
|
|
12
|
-
This Client SDK provides
|
13
|
+
This Client SDK provides extensions necessary for translating Rails based application using the Tr8nHub service.
|
13
14
|
|
14
15
|
|
15
|
-
|
16
|
+
Tr8n Client SDK Sample
|
16
17
|
===================================
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
Add the following gem to your Gemfile:
|
21
|
-
|
22
|
-
```ruby
|
23
|
-
gem 'tr8n_client_sdk', '~> 3.3'
|
24
|
-
```
|
25
|
-
|
26
|
-
Install the gems:
|
19
|
+
The best way to start using Tr8nHub is to run the sample application that comes bundled with this SDK.
|
27
20
|
|
28
21
|
```sh
|
29
|
-
$
|
22
|
+
$ git clone https://github.com/tr8n/tr8n_rails_clientsdk.git
|
23
|
+
$ cd tr8n_rails_clientsdk/spec/dummy
|
24
|
+
$ bundle
|
25
|
+
$ script/rails s
|
30
26
|
```
|
31
27
|
|
28
|
+
This will start the dummy application in development mode. The development mode uses Tr8nHub sandbox server for translations.
|
32
29
|
|
33
|
-
Configuration
|
34
|
-
===================================
|
35
30
|
|
36
|
-
|
31
|
+
Alternatively, you can use the same sample application as a stand alone app:
|
37
32
|
|
38
|
-
|
33
|
+
https://github.com/tr8n/tr8n_rails_clientsdk_sample
|
39
34
|
|
40
|
-
|
41
|
-
Tr8n.configure do |config|
|
42
|
-
config.application = {
|
43
|
-
:key => YOUR_APP_KEY,
|
44
|
-
:secret => YOUR_APP_SECRET
|
45
|
-
}
|
46
|
-
end
|
47
|
-
```
|
35
|
+
This application is running at:
|
48
36
|
|
49
|
-
|
37
|
+
http://rails.tr8nhub.com
|
50
38
|
|
51
|
-
If you are already using Rails caching, you probably already specify it in your production file, like the following:
|
52
39
|
|
53
|
-
config/environments/production.rb
|
54
40
|
|
55
|
-
|
56
|
-
|
57
|
-
config.identity_cache_store = :mem_cache_store, Dalli::Client.new('localhost:11211', {:namespace => 'myapplication'})
|
58
|
-
```
|
41
|
+
Integration Instructions
|
42
|
+
===================================
|
59
43
|
|
60
|
-
|
44
|
+
To integrate Tr8n SDK into your app, all you need to do is:
|
61
45
|
|
62
|
-
|
46
|
+
Add the following gems to your Gemfile:
|
63
47
|
|
64
48
|
```ruby
|
65
|
-
|
66
|
-
config.cache = {
|
67
|
-
:enabled => true,
|
68
|
-
:adapter => 'rails',
|
69
|
-
:version => 1
|
70
|
-
}
|
71
|
-
end
|
49
|
+
gem 'tr8n_client_sdk'
|
72
50
|
```
|
73
51
|
|
74
|
-
|
52
|
+
Install the gems:
|
75
53
|
|
76
|
-
```
|
77
|
-
|
78
|
-
config.cache = {
|
79
|
-
:enabled => true,
|
80
|
-
:adapter => 'memcache',
|
81
|
-
:host => 'localhost:11211',
|
82
|
-
:version => 1,
|
83
|
-
:timeout => 3600
|
84
|
-
}
|
85
|
-
end
|
54
|
+
```sh
|
55
|
+
$ bundle
|
86
56
|
```
|
87
57
|
|
88
|
-
|
58
|
+
Add the following configuration to your Application.rb (or to the various environment files):
|
89
59
|
|
90
60
|
```ruby
|
91
|
-
Tr8n.configure do |config|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
:timeout => 3600
|
98
|
-
}
|
99
|
-
end
|
61
|
+
Tr8n.configure do |config|
|
62
|
+
config.application = {
|
63
|
+
:key => YOUR_APP_KEY,
|
64
|
+
:secret => YOUR_APP_SECRET
|
65
|
+
}
|
66
|
+
end
|
100
67
|
```
|
101
68
|
|
102
|
-
|
103
|
-
will save you memory space, as well as allow you to invalidate/redeploy your translations cache without having to redeploy your application.
|
104
|
-
|
105
|
-
To update the cache, execute the following line of code:
|
69
|
+
In the HEAD section of your layout, add:
|
106
70
|
|
107
71
|
```ruby
|
108
|
-
|
109
|
-
```
|
110
|
-
|
111
|
-
Or you can run the rake command from any of your app instances:
|
112
|
-
|
113
|
-
```sh
|
114
|
-
$ bundle exec rake tr8n:cache:upgrade
|
72
|
+
<%= tr8n_scripts_tag %>
|
115
73
|
```
|
116
74
|
|
117
|
-
|
75
|
+
You are done, tr8n is now running in your app.
|
118
76
|
|
119
|
-
|
120
|
-
but it will be faster at serving translations and this approach does not require cache warmup.
|
121
|
-
|
122
|
-
To specify in-memory, file-based cache, provide the following configuration:
|
77
|
+
Now you can simply add the default language selector anywhere on your page using:
|
123
78
|
|
124
79
|
```ruby
|
125
|
-
|
126
|
-
config.cache = {
|
127
|
-
:enabled => true,
|
128
|
-
:adapter => 'file',
|
129
|
-
:path => 'config/tr8n',
|
130
|
-
:version => 'current',
|
131
|
-
:segmented => false
|
132
|
-
}
|
133
|
-
end
|
80
|
+
<%= tr8n_language_selector_tag %>
|
134
81
|
```
|
135
82
|
|
136
|
-
|
137
|
-
|
138
|
-
The file based cache must be generated before you deploy your application using the following command:
|
83
|
+
And use TML (Translation Markup Language) to translate your strings, using:
|
139
84
|
|
140
|
-
```
|
141
|
-
|
85
|
+
```rails
|
86
|
+
<%= tr("Hello World") %>
|
87
|
+
<%= tr("You have {count||message}", :count => 5) %>
|
88
|
+
<%= tr("{actor} sent {target} [bold: {count||gift}]", :actor => actor_user, :target => target_user, :count => 5) %>
|
89
|
+
...
|
142
90
|
```
|
143
91
|
|
144
|
-
|
145
|
-
|
146
|
-
```sh
|
147
|
-
$ bundle exec rake tr8n:cache:rollback
|
148
|
-
```
|
92
|
+
Learn more about TML at: http://wiki.tr8nhub.com
|
149
93
|
|
150
94
|
|
151
|
-
|
95
|
+
Caching
|
152
96
|
===================================
|
153
97
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
<%= tr8n_scripts_tag %>
|
158
|
-
```
|
159
|
-
|
160
|
-
Now you can simply add the default language selector anywhere on your page using:
|
161
|
-
|
162
|
-
```ruby
|
163
|
-
<%= tr8n_language_selector_tag %>
|
164
|
-
```
|
165
|
-
|
166
|
-
The default language selector is used to enable/disable translation modes. It may be useful on staging or translation
|
167
|
-
server, but it may not be ideal on production. There are a number of alternative language selectors you can use, including your own.
|
168
|
-
|
169
|
-
To use a dropdown language selector that uses locale in the url parameter, use:
|
170
|
-
|
171
|
-
```ruby
|
172
|
-
<%= tr8n_language_selector_tag(
|
173
|
-
:type => :dropdown,
|
174
|
-
:style => "margin-top:15px",
|
175
|
-
:language => :english
|
176
|
-
) %>
|
177
|
-
```
|
178
|
-
|
179
|
-
Now you can use Tr8n's helper methods and TML (Translation Markup Language) to translate your strings:
|
180
|
-
|
181
|
-
```ruby
|
182
|
-
<%= tr("Hello World") %>
|
183
|
-
<%= tr("You have {count || message}", count: 5) %>
|
184
|
-
<%= tr("{actor} sent {target} [bold: {count || gift}]", actor: actor_user, target: target_user, count: 5) %>
|
185
|
-
<%= tr("{actor} uploaded [bold: {count || photo}] to {actor | his, her} photo album.", actor: current_user, count: 5) %>
|
186
|
-
...
|
187
|
-
```
|
98
|
+
You should enable caching for your application. Without caching you will be querying the service for new translations on every page load.
|
99
|
+
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.
|
100
|
+
For all other users you should serve translations from your cache.
|
188
101
|
|
189
|
-
|
190
|
-
you can simply use:
|
102
|
+
To enable cache, simply add the following configuration to Tr8n config:
|
191
103
|
|
192
104
|
```ruby
|
193
|
-
|
105
|
+
Tr8n.configure do |config|
|
106
|
+
config.cache = {
|
107
|
+
:enabled => true,
|
108
|
+
:adapter => 'memcache',
|
109
|
+
:host => 'localhost:11211',
|
110
|
+
:version => 2,
|
111
|
+
:timeout => 3600
|
112
|
+
}
|
113
|
+
end
|
194
114
|
```
|
195
115
|
|
196
|
-
|
116
|
+
The following Cache adapters are supported:
|
197
117
|
|
118
|
+
Memcache, Redis, CDB, File
|
198
119
|
|
199
|
-
|
200
|
-
===================================
|
120
|
+
It is easy to add any other custom cache adapter as well.
|
201
121
|
|
202
|
-
|
203
|
-
you need to set the i18n backend to Tr8n. Add the following line to your tr8n initializer:
|
122
|
+
Memcache and Redis adapters can do a realtime cache warmup - by loading the translations from the service and storing them in the cache.
|
204
123
|
|
205
|
-
|
124
|
+
To reset/upgrade your cache, you can simply call
|
206
125
|
|
207
126
|
```ruby
|
208
|
-
|
127
|
+
Tr8n.cache.upgrade_version
|
209
128
|
```
|
210
129
|
|
211
|
-
|
130
|
+
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.
|
212
131
|
|
213
|
-
config/locales/en.yml
|
214
132
|
|
215
|
-
|
216
|
-
en:
|
217
|
-
hello: "Hello world"
|
218
|
-
my:
|
219
|
-
nested:
|
220
|
-
key: "This is a nested key"
|
221
|
-
```
|
133
|
+
CDB and File adapters require pre-generation. You can pre-generate your cache by running:
|
222
134
|
|
223
|
-
|
224
|
-
|
225
|
-
```ruby
|
226
|
-
<%= t(:hello) %>
|
227
|
-
<%= t("my.nested.key") %>
|
135
|
+
```sh
|
136
|
+
$ rake tr8n:generate_cache:file
|
228
137
|
```
|
229
138
|
|
230
|
-
|
139
|
+
or
|
231
140
|
|
232
|
-
```
|
233
|
-
|
234
|
-
<%= tr("This is a nested key") %>
|
141
|
+
```sh
|
142
|
+
$ rake tr8n:generate_cache:cdb
|
235
143
|
```
|
236
144
|
|
237
|
-
|
145
|
+
You can also do a combination of file-based adapters (for persistent cache) and memory-based adapters for serving the translations.
|
238
146
|
|
239
147
|
|
240
148
|
Logging
|
@@ -243,28 +151,29 @@ Logging
|
|
243
151
|
Tr8n comes with its own logger. If you would like to see what the SDK is doing behind the scene, enable the logger and provide the file path for the log file:
|
244
152
|
|
245
153
|
```ruby
|
246
|
-
Tr8n.configure do |config|
|
154
|
+
Tr8n.configure do |config|
|
247
155
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
156
|
+
config.logger = {
|
157
|
+
:enabled => true,
|
158
|
+
:path => "#{Rails.root}/log/tr8n.log",
|
159
|
+
:level => 'debug'
|
160
|
+
}
|
253
161
|
|
254
|
-
end
|
162
|
+
end
|
255
163
|
```
|
256
164
|
|
257
|
-
|
165
|
+
|
166
|
+
Rules Engine Customizations
|
258
167
|
===================================
|
259
168
|
|
260
169
|
Tr8n comes with default settings for the rules engine. For example, it assumes that you have the following methods in your ApplicationController:
|
261
170
|
|
262
171
|
```ruby
|
263
|
-
def current_user
|
264
|
-
end
|
172
|
+
def current_user
|
173
|
+
end
|
265
174
|
|
266
|
-
def current_locale
|
267
|
-
end
|
175
|
+
def current_locale
|
176
|
+
end
|
268
177
|
```
|
269
178
|
|
270
179
|
Tr8n only needs the current_user method if your site needs to use gender based rules for the viewing user.
|
@@ -274,84 +183,18 @@ Similarly, if you prefer to use your own mechanism for storing and retrieving us
|
|
274
183
|
If you need to adjust those method names, you can set them in the config:
|
275
184
|
|
276
185
|
```ruby
|
277
|
-
Tr8n.configure do |config|
|
186
|
+
Tr8n.configure do |config|
|
278
187
|
|
279
|
-
|
188
|
+
config.current_user_method = :my_user
|
280
189
|
|
281
|
-
|
190
|
+
config.current_locale_method = :my_locale
|
282
191
|
|
283
|
-
end
|
192
|
+
end
|
284
193
|
```
|
285
194
|
|
286
195
|
|
287
|
-
Tr8n Client SDK Sample
|
288
|
-
===================================
|
289
|
-
|
290
|
-
The best way to start using the SDK is to run a sample application that comes bundled with this SDK.
|
291
|
-
|
292
|
-
```sh
|
293
|
-
$ git clone https://github.com/tr8n/tr8n_rails_clientsdk.git
|
294
|
-
$ cd tr8n_rails_clientsdk/spec/dummy
|
295
|
-
$ bundle
|
296
|
-
```
|
297
|
-
|
298
|
-
Before you running the application, visit TranslationExchange.com, register as a new user and create a new application.
|
299
|
-
|
300
|
-
Update your key and secret in the following file: config/initializers/tr8n.rb
|
301
|
-
|
302
|
-
```ruby
|
303
|
-
config.application = {
|
304
|
-
:key => YOUR_KEY,
|
305
|
-
:secret => YOUR_SECRET
|
306
|
-
}
|
307
|
-
```
|
308
|
-
|
309
|
-
Now you can start the application by running:
|
310
|
-
|
311
|
-
```sh
|
312
|
-
$ bundle exec rails s
|
313
|
-
```
|
314
|
-
|
315
|
-
|
316
|
-
This will start the dummy application on port 3000. Open your browser and point to:
|
317
|
-
|
318
|
-
http://localhost:3000
|
319
|
-
|
320
|
-
|
321
|
-
Links
|
322
|
-
==================
|
323
|
-
|
324
|
-
* Register on TranslationExchange.com: http://translationexchange.com
|
325
|
-
|
326
|
-
* Read Translation Exchange documentation: http://translationexchange.com/docs
|
327
|
-
|
328
|
-
* Follow TranslationExchange on Twitter: https://twitter.com/translationx
|
329
|
-
|
330
|
-
* Connect with TranslationExchange on Facebook: https://www.facebook.com/translationexchange
|
331
|
-
|
332
|
-
* If you have any questions or suggestions, contact us: feedback@translationexchange.com
|
333
|
-
|
334
|
-
|
335
|
-
Copyright and license
|
336
|
-
==================
|
337
|
-
|
338
|
-
Copyright (c) 2015 Translation Exchange Inc, TranslationExchange.com
|
339
196
|
|
340
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
341
|
-
a copy of this software and associated documentation files (the
|
342
|
-
"Software"), to deal in the Software without restriction, including
|
343
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
344
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
345
|
-
permit persons to whom the Software is furnished to do so, subject to
|
346
|
-
the following conditions:
|
347
197
|
|
348
|
-
|
349
|
-
included in all copies or substantial portions of the Software.
|
198
|
+
To read more about what you can do with Tr8n, visit the wiki site:
|
350
199
|
|
351
|
-
|
352
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
353
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
354
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
355
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
356
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
357
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
200
|
+
http://wiki.tr8nhub.com
|
data/Rakefile
CHANGED
@@ -1,34 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2015 Translation Exchange Inc. http://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
1
|
#!/usr/bin/env rake
|
33
2
|
#begin
|
34
3
|
# require 'bundler/setup'
|
@@ -52,6 +21,22 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
52
21
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
22
|
end
|
54
23
|
|
24
|
+
#APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
25
|
+
#load 'rails/tasks/engine.rake'
|
26
|
+
#
|
27
|
+
#Dir["#{File.dirname(__FILE__)}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
|
28
|
+
#
|
29
|
+
#Bundler::GemHelper.install_tasks
|
30
|
+
#
|
31
|
+
#require 'rake/testtask'
|
32
|
+
#
|
33
|
+
#Rake::TestTask.new(:test) do |t|
|
34
|
+
# t.libs << 'lib'
|
35
|
+
# t.libs << 'test'
|
36
|
+
# t.pattern = 'test/**/*_test.rb'
|
37
|
+
# t.verbose = false
|
38
|
+
#end
|
39
|
+
|
55
40
|
Dir["#{File.dirname(__FILE__)}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
|
56
41
|
|
57
42
|
require 'rspec/core/rake_task'
|
@@ -1,53 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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.english_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
|
-
|
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.english_name %>
|
51
|
-
<% end %>
|
52
|
-
</a>
|
53
|
-
<% end %>
|
1
|
+
<a href="#" onClick="Tr8n.UI.LanguageSelector.show()">
|
2
|
+
<%= image_tag(tr8n_current_language.flag_url, :style => "align:middle") %>
|
3
|
+
|
4
|
+
<%= tr8n_current_language.name %>
|
5
|
+
</a>
|
@@ -1,17 +1,17 @@
|
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
12
|
+
<%= tr8n_language_name_tag(lang, opts) %>
|
13
13
|
<% end %>
|
14
|
-
|
14
|
+
|
15
15
|
<% if featured_languages.size > 0 %>
|
16
16
|
<%=link_to_function("»".html_safe, "Tr8n.UI.LanguageSelector.show()") %>
|
17
17
|
<% end %>
|
@@ -1,18 +1,6 @@
|
|
1
1
|
<div style="padding-top:40px; color: #ccc; text-align:center; width:100%">
|
2
|
-
<%= tr("Powered by {
|
3
|
-
|
4
|
-
|
5
|
-
.trex_logo {
|
6
|
-
margin-top:10px;
|
7
|
-
padding: 40px;
|
8
|
-
background-repeat: no-repeat;
|
9
|
-
background-image:url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAEMAAABQCAYAAABCiMhGAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpCQTg4MTEyOEU0NkIxMUUzODhCMEJEOUNDRDQ0QkU0MiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpCQTg4MTEyOUU0NkIxMUUzODhCMEJEOUNDRDQ0QkU0MiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkJBODgxMTI2RTQ2QjExRTM4OEIwQkQ5Q0NENDRCRTQyIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkJBODgxMTI3RTQ2QjExRTM4OEIwQkQ5Q0NENDRCRTQyIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+mszKSAAAAqFJREFUeNrsnE1IFVEYhr+53QiKEIkgpCBwJSH9SITkqkVELXJZ0iYIqRaBCZWgoWKikRBI1KVNmyg3gVKQ0CZE+9kHQYukaGP2I6iEP1ffc+dc7iwK5s5Mx3PPvC88zGxm5s4zc85853JmvNardwTxwC1wGuyWdGQGvARduaH23wUJkJHFcgoclnTmKzgIIT8yWOlNsQiVPeB+8c74hmWNMNXqzqimh0JqlIxVeigkr2Tk6aGQtQwdlEIZlEEZlEEZEZONuf0YmASLYNNGPRI1e8FFsHUjZNwAg5Zd3GHwHuw02Uw+WShCZRr0m+4zPljc9D+alpG1WMYW0zJsfgplxMGTYp1BGZRBGZRBGZRBGZRBGZRBGZRBGQxlUAZlUAZlUAZlUAZlUAZlUAZlUIbDMmyeYr3KO6OUJdMyGiyWcdS0DPV+ykMLRRwD16JuHGc60gV9Fd6KP/Vxs/hTEDvBbIT9nQLNEdp8XkpTH0/GMRl3bladJpi7EWQcB89dfLSW24EdAeOsM0T2gQkWXX4bf6P7mlTL2KFFbE97Ob4NvAO70j42UcdTbyHU2jo28Qwe7zXYb2nl6mXE3DzwF6DJ5kGrkjFv4EBP4laHBjKjZDz7zwfJgTOWi3iVG2qfVTKui//ZhMTaXmD9Hmi1XMSf4m9UMubAIfAY/Epg58t62QcuWyxhQfx37A7grvgcHKipgdU5UPWX538LuBlh8Deu+4oVS2X8BN8h4p+j1jlNMOW+5lQ8+QmpsIQpusr5vsYV8EUqNElWoKojHpYKTlIyusFtqfAkIWMA9IgDiStD/cXXIY4kjowHoE0cSlQZj8AlcSxRZDwF58XBhJGxFlgfBWfF0YSR4QXK62ZxOGFk1OtR7QlxPGFkjIBGSUHWBRgAlJNpO4bVinwAAAAASUVORK5CYII=);
|
10
|
-
}
|
11
|
-
</style>
|
12
|
-
|
13
|
-
<div style="text-align: center">
|
14
|
-
<%=link_to('http://translationexchange.com') do %>
|
15
|
-
<img class="trex_logo" src="" alt="" />
|
16
|
-
<% end %>
|
2
|
+
<%= tr("Powered by {tr8n}", :tr8n => link_to("Tr8n", "http://wiki.tr8nhub.com", :style=>"color:#ccc;")) %>
|
3
|
+
<div style="padding-top:5px;">
|
4
|
+
<%=link_to(image_tag("http://wiki.tr8nhub.com/images/e/e9/Tr8n_logo.png", :style=>"width:50px;"), "http://wiki.tr8nhub.com") %>
|
17
5
|
</div>
|
18
6
|
</div>
|