translation_engine 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: 56c507d1510239faa143eebb8ee3fc350838b89e752ade64eabb2eb29ba744d4
4
- data.tar.gz: ed3aa9700cf740cffe558a81760cb589f53312bb89a1ef42174aa6d57e45ff6c
3
+ metadata.gz: 8504f4c93d33bebfd84f224caf9cbeaf75cc2754ad9a4616ff6d2fe6aab4c1ec
4
+ data.tar.gz: d2c7782ee74fa7f5ce69629406d8bd076ed51b6b28e5a7cb2f1f06e3e15d9a9c
5
5
  SHA512:
6
- metadata.gz: 3dffd883dd889cb1125f96fd018c8466cb761f96eceadbd40fc7d37df2cfa4554a27d574db43e3de6845cc68d6e194375656fa7feeffb9f26494174ed7c4e2fc
7
- data.tar.gz: ce760583ae6c6e176950e7b230be2ee66d4054c3992dd3661d85fb77dead5d3412fc43ab208e61323f5d7949e0af9618df927d22f38303a6f878a8e93c2bab12
6
+ metadata.gz: fe9249300f13201dcc6efdcc97f69ec94ef672490875eb877eff59df116b342adc8962532d3f52110bc06bfdd1e20f644c8b70e343ca2bac1e263d0b479bdce0
7
+ data.tar.gz: af56402ee4b345ee64b532c237b401a47b545ab7f96465165a538d01028e7eed2443ad9b47668a971a8f14af94406adfda8a894329c05acb9d16e68279578707
data/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # TranslationEngine [![Dependency Status](https://dependencyci.com/github/blueberryapps/translation-engine/badge)](https://dependencyci.com/github/blueberryapps/translation-engine)
2
+
3
+ ```
4
+ gem 'translation_engine', git: 'https://github.com/blueberryapps/translation-engine.git'
5
+ ```
6
+
7
+ ## Configuration
8
+
9
+ Default configuration is that all part are turned off, so for enabling you need
10
+ to create file `config/initializers/translation_engine.rb` with this content:
11
+
12
+ ```ruby
13
+ # config/initializers/translation_engine.rb
14
+
15
+ TranslationEngine.config do |config|
16
+ # key for user
17
+ config.api_key = 'API_KEY'
18
+
19
+ # url to Translation Server
20
+ config.api_host = 'http://127.0.0.1:3000'
21
+
22
+ # enable screenshot functionality (default is false)
23
+ config.use_screenshots = true
24
+
25
+ # enable to send translation after every request and receive translations
26
+ # when something changed (default is false)
27
+ config.use_catcher = true
28
+
29
+ # for production envs you don't want to send translations
30
+ # so if use_catcher is true you can disable sending them by this option:
31
+ config.disable_sending_translations = true
32
+
33
+ # Timeout for connecting to translation server
34
+ # config.timeout = 5
35
+
36
+ # Set time between asking translation server for new data, (default is 0)
37
+ config.cache_timeout = 60 # ask translation server every 60s for new data
38
+
39
+ # If true TranslationEngine will throw exceptions on connection problems
40
+ # If false TranslationEngine will just log exception to Rails.logger
41
+ config.raise_exceptions = Rails.env.development?
42
+ end
43
+ ```
44
+
45
+ ## Releases
46
+
47
+ ```
48
+ # list all possible releases
49
+ I18n.backend.releases
50
+
51
+ # list all possible release which has same locale as I18n.locale
52
+ I18n.backend.current_locale_releases
53
+ ```
54
+ ### Switch release on frontend
55
+
56
+ ```slim
57
+ - I18n.backend.current_locale_releases.each do |release|
58
+ = link_to release.version.upcase,
59
+ { translation_release: release.version },
60
+ class: ('active' if release.current?)
61
+ ```
62
+
63
+ ## Screenshots Integration
64
+
65
+ ### Javascript
66
+ Require javascript by inserting `app/assets/javascripts/application.js`
67
+ ```
68
+ //= require translation_engine/screenshots
69
+ ```
70
+ or in views `= javascript_include_tag 'translation_engine/screenshots'`
71
+ (this javascript is already precompiled, so you don't need to do anything else)
72
+
73
+ Ensure that you have jquery + coffeescript
74
+ (or similar gems which provides same function)
75
+
76
+ ```ruby
77
+ gem 'coffee-rails'
78
+ gem 'jquery-rails'
79
+ ```
80
+
81
+ ### Stylesheets
82
+ Require stylesheets by inserting `app/assets/stylesheets/application.sass`:
83
+
84
+ ```
85
+ @import 'translation_engine/screenshots'
86
+ ```
87
+
88
+ or in views `= stylesheet_link_tag 'translation_engine/screenshots'`
89
+ (this stylesheet is already precompiled, so you don't need to do anything else)
90
+
91
+ ### Start translations screenshoting
92
+ Create element with class `translation_engine_start`.
93
+ When you click on this element, Translation Engine will start screenshoting page
94
+ and then sends all images + highlights to server `/transaltion_engine` which
95
+ will be catched by `ScreenshotsMiddleware` and then send to TranslationServer.
96
+
97
+ or
98
+
99
+ Use callback `window.TranslationEngine.start()`
100
+
101
+ ### Show translations and keys + link to translation server
102
+ Create element with class `translation_highlight_start`.
103
+
104
+ When you click on this element, Translation Engine will show keys instead of text to all
105
+ translated text in page and it will add link to translation server.
106
+
107
+ or
108
+
109
+ Use callback `window.TranslationEngine.highlight()`
110
+
111
+ ## Rake tasks
112
+
113
+ ### `rake translation_engine:list:releases`
114
+
115
+ List all available releases from Translations Server
116
+
117
+
118
+ ### `rake translation_engine:pull:master`
119
+
120
+ Download all master translations from Translations server and store them
121
+ into config/locales/z_translation_engine.yml
122
+
123
+ ### `rake translation_engine:pull:release RELEASE=en_v001`
124
+
125
+ Download released translations from Translations server and store them
126
+ into config/locales/z_releases/(release_locale).yml,
127
+ will overwrite previous locale release, leaving allways only one release.
128
+
129
+ ## Architecture of service
130
+
131
+ ![Catcher](./readme/catcher.png)
132
+
133
+ Catcher is middleware in rails APP which catches all used translations in page
134
+ and then it sends them into Translation Server.
135
+
136
+ ![Screenshots](./readme/screenshots.png)
137
+
138
+ Screenshots middleware takes highlights and images which sends into Translation
139
+ Server.
140
+
141
+ ## Publishing
142
+
143
+ ```
144
+ gem build translation_engine.gemspec
145
+ gem push translation_engine-0.0.5.gem
146
+ ```
@@ -1,3 +1,5 @@
1
+ require_relative 'request'
2
+
1
3
  module TranslationEngine
2
4
  class CatcherMiddleware
3
5
  include Request
@@ -1,3 +1,5 @@
1
+ require_relative 'request'
2
+
1
3
  module TranslationEngine
2
4
  class KeysMiddleware
3
5
 
@@ -1,3 +1,5 @@
1
+ require_relative 'request'
2
+
1
3
  module TranslationEngine
2
4
  class ScreenshotsMiddleware
3
5
  include Request
@@ -1,3 +1,8 @@
1
+ require_relative '../../app/middlewares/translation_engine/catcher_middleware'
2
+ require_relative '../../app/middlewares/translation_engine/connection_exception_middleware'
3
+ require_relative '../../app/middlewares/translation_engine/keys_middleware'
4
+ require_relative '../../app/middlewares/translation_engine/screenshots_middleware'
5
+
1
6
  module TranslationEngine
2
7
  class Engine < ::Rails::Engine
3
8
  isolate_namespace TranslationEngine
@@ -61,4 +66,3 @@ module TranslationEngine
61
66
  end
62
67
  end
63
68
  end
64
-
@@ -1,3 +1,3 @@
1
1
  module TranslationEngine
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require_relative "boot"
2
2
 
3
3
  require 'rails/all'
4
4
 
@@ -23,4 +23,3 @@ module Dummy
23
23
  config.active_record.raise_in_transactional_callbacks = true
24
24
  end
25
25
  end
26
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translation_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-19 00:00:00.000000000 Z
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -88,6 +88,7 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - MIT-LICENSE
91
+ - README.md
91
92
  - Rakefile
92
93
  - app/assets/javascripts/translation_engine/html2canvas.js
93
94
  - app/assets/javascripts/translation_engine/screenshots.js.coffee
@@ -156,7 +157,7 @@ homepage: http://blueberry.cz
156
157
  licenses:
157
158
  - MIT
158
159
  metadata: {}
159
- post_install_message:
160
+ post_install_message:
160
161
  rdoc_options: []
161
162
  require_paths:
162
163
  - lib
@@ -171,51 +172,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
172
  - !ruby/object:Gem::Version
172
173
  version: '0'
173
174
  requirements: []
174
- rubygems_version: 3.3.7
175
- signing_key:
175
+ rubygems_version: 3.0.3.1
176
+ signing_key:
176
177
  specification_version: 4
177
178
  summary: Connects Rails application to Translation Server
178
179
  test_files:
179
- - test/dummy/README.rdoc
180
- - test/dummy/Rakefile
181
- - test/dummy/app/assets/javascripts/application.js
182
- - test/dummy/app/assets/javascripts/root.js
183
- - test/dummy/app/assets/stylesheets/application.css
184
- - test/dummy/app/assets/stylesheets/root.css
180
+ - test/translation_engine_test.rb
185
181
  - test/dummy/app/controllers/application_controller.rb
186
182
  - test/dummy/app/controllers/root_controller.rb
187
- - test/dummy/app/helpers/application_helper.rb
188
- - test/dummy/app/helpers/root_helper.rb
189
183
  - test/dummy/app/views/layouts/application.html.erb
190
184
  - test/dummy/app/views/root/index.html.erb
191
- - test/dummy/bin/bundle
192
- - test/dummy/bin/rails
185
+ - test/dummy/app/assets/javascripts/root.js
186
+ - test/dummy/app/assets/javascripts/application.js
187
+ - test/dummy/app/assets/stylesheets/application.css
188
+ - test/dummy/app/assets/stylesheets/root.css
189
+ - test/dummy/app/helpers/root_helper.rb
190
+ - test/dummy/app/helpers/application_helper.rb
191
+ - test/dummy/test/controllers/root_controller_test.rb
193
192
  - test/dummy/bin/rake
194
193
  - test/dummy/bin/setup
195
- - test/dummy/config/application.rb
196
- - test/dummy/config/boot.rb
197
- - test/dummy/config/database.yml
198
- - test/dummy/config/environment.rb
199
- - test/dummy/config/environments/development.rb
194
+ - test/dummy/bin/bundle
195
+ - test/dummy/bin/rails
196
+ - test/dummy/config/secrets.yml
197
+ - test/dummy/config/routes.rb
198
+ - test/dummy/config/locales/en.yml
200
199
  - test/dummy/config/environments/production.rb
200
+ - test/dummy/config/environments/development.rb
201
201
  - test/dummy/config/environments/test.rb
202
- - test/dummy/config/initializers/assets.rb
202
+ - test/dummy/config/environment.rb
203
+ - test/dummy/config/application.rb
204
+ - test/dummy/config/database.yml
205
+ - test/dummy/config/boot.rb
203
206
  - test/dummy/config/initializers/backtrace_silencers.rb
204
- - test/dummy/config/initializers/cookies_serializer.rb
205
- - test/dummy/config/initializers/filter_parameter_logging.rb
206
- - test/dummy/config/initializers/inflections.rb
207
+ - test/dummy/config/initializers/translation_engine.rb
207
208
  - test/dummy/config/initializers/mime_types.rb
209
+ - test/dummy/config/initializers/filter_parameter_logging.rb
208
210
  - test/dummy/config/initializers/session_store.rb
209
- - test/dummy/config/initializers/translation_engine.rb
210
211
  - test/dummy/config/initializers/wrap_parameters.rb
211
- - test/dummy/config/locales/en.yml
212
- - test/dummy/config/routes.rb
213
- - test/dummy/config/secrets.yml
212
+ - test/dummy/config/initializers/assets.rb
213
+ - test/dummy/config/initializers/cookies_serializer.rb
214
+ - test/dummy/config/initializers/inflections.rb
214
215
  - test/dummy/config.ru
215
- - test/dummy/public/404.html
216
+ - test/dummy/Rakefile
217
+ - test/dummy/public/favicon.ico
216
218
  - test/dummy/public/422.html
217
219
  - test/dummy/public/500.html
218
- - test/dummy/public/favicon.ico
219
- - test/dummy/test/controllers/root_controller_test.rb
220
+ - test/dummy/public/404.html
221
+ - test/dummy/README.rdoc
220
222
  - test/test_helper.rb
221
- - test/translation_engine_test.rb