translation_engine 0.0.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac95cf9c6d16b490a19aaeedae0ea1caa3c6243c97cb4d9ed2ba9f7106b8988b
4
- data.tar.gz: 5510294287f26bdf0abe67d12b28c65013e1633e0b2b478bbffd1fba5fe10947
3
+ metadata.gz: 8504f4c93d33bebfd84f224caf9cbeaf75cc2754ad9a4616ff6d2fe6aab4c1ec
4
+ data.tar.gz: d2c7782ee74fa7f5ce69629406d8bd076ed51b6b28e5a7cb2f1f06e3e15d9a9c
5
5
  SHA512:
6
- metadata.gz: 9f1ba7e2297b1a93bc783cd2f8009d49cb8666af916801c75593a1fb5ee582d4c3a60e2902f0110ccaebd3271ed69d390dc7f5f6cd261ee381dda4a3f8eb4796
7
- data.tar.gz: 647279a4752922e40ed772171597f234caf4a630f45d576c88902bef29eb5db942c2b213a211485d21ac9b545b0129272b38af77f325687013893e616c476819
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
@@ -56,10 +56,10 @@ class TranslationEngine::Backend < I18n::Backend::Simple
56
56
  result = catch(:exception) do
57
57
  case subject
58
58
  when Symbol
59
- I18n.translate(subject, options.merge(:locale => locale, :throw => true))
59
+ I18n.translate(subject, **options.merge(:locale => locale, :throw => true))
60
60
  when Proc
61
61
  date_or_time = options.delete(:object) || object
62
- resolve(locale, object, subject.call(date_or_time, options))
62
+ resolve(locale, object, subject.call(date_or_time, **options))
63
63
  when nil
64
64
  nil
65
65
  else
@@ -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.0.8"
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.0.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-30 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
@@ -145,7 +146,6 @@ files:
145
146
  - test/dummy/config/locales/en.yml
146
147
  - test/dummy/config/routes.rb
147
148
  - test/dummy/config/secrets.yml
148
- - test/dummy/log/test.log
149
149
  - test/dummy/public/404.html
150
150
  - test/dummy/public/422.html
151
151
  - test/dummy/public/500.html
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  requirements: []
175
- rubygems_version: 3.0.1
175
+ rubygems_version: 3.0.3.1
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: Connects Rails application to Translation Server
@@ -218,6 +218,5 @@ test_files:
218
218
  - test/dummy/public/422.html
219
219
  - test/dummy/public/500.html
220
220
  - test/dummy/public/404.html
221
- - test/dummy/log/test.log
222
221
  - test/dummy/README.rdoc
223
222
  - test/test_helper.rb
File without changes