rosetta 1.1.0 → 1.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
  SHA256:
3
- metadata.gz: 8e31624af10b6499013ddde8239abb0b47d8e48889c307cc199174a995b694c5
4
- data.tar.gz: 0aba8bf9b7a78145977432ea5447a747a0b79635709861af2cc1aa014f6694a6
3
+ metadata.gz: 00126b0010fc67571301c60501085cfc4f5b7b24a5018898aa69ed5838aa8dab
4
+ data.tar.gz: 94e139c15399152cc9873be0dc49468a6ed857cd21f877e8888327c44eeb0ab3
5
5
  SHA512:
6
- metadata.gz: d452e7461c1d241abc9c62f3616859abb850a5bc039d6876655e5394262eec812bc19c078f35e8826b9fcc51a74bb19214a3874f45851f65df8a880ba819d29b
7
- data.tar.gz: fdc89894c0fd83321e7b5be821a1120f30614d58d356d2a58e325d9811a6f2d63e5181f333889ff4ca3979910f27a59940623338707b84042c103e5b9b99a8a2
6
+ metadata.gz: b621efdc6079463080d11c2af4d55a35c78f0817642f3fd64f2a99fb349b4e209347fa6c84462df0491b7926ad84d31836addb3b5e2b8a301cb381986acd2ac0
7
+ data.tar.gz: a9407323c95d75ce0bf6514d67edc938f1f586041a7195eb79f1b50d75047573978763073bf19fd0374e82e9ecf4aec07b5618e8a666c1861b7173ec881c925c
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rosetta
4
+ class BaseController < ActionController::Base
5
+ end
6
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rosetta
4
+ module DatabaseRepository
5
+ class PhrasesController < BaseController
6
+
7
+ def update
8
+ load_or_create_phrase
9
+ build_phrase
10
+
11
+ if @phrase.save
12
+ I18n.backend.reload!
13
+ else
14
+ flash[:rosetta_alert] = 'Your new translation not saved.'
15
+ end
16
+
17
+ redirect_to params[:current_path]
18
+ end
19
+
20
+ def load_or_create_phrase
21
+ key = params[:id]
22
+ locale = I18n.locale
23
+
24
+ @phrase = Translation.find_by(key: key, locale: locale) ||
25
+ Translation.new(key: key, locale: locale)
26
+ end
27
+
28
+ def build_phrase
29
+ @phrase.attributes = params&.permit(
30
+ :value
31
+ ) || {}
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -179,6 +179,11 @@
179
179
  transform: translate(-50%, -50%);
180
180
  }
181
181
 
182
+ .database__field{
183
+ min-width: 100%;
184
+ max-height: 150px important!;
185
+ }
186
+
182
187
  </style>
183
188
 
184
189
  <div id="phrasesMenu" class="phrases-menu <%= Rosetta.repository.id %>">
@@ -213,6 +218,8 @@
213
218
  <script type="text/javascript">
214
219
  /* Toggle the Translate menu */
215
220
  $( document ).ready(function() {
221
+ var outPhrasesMenu = true;
222
+
216
223
  var searchSelectedText = function(){
217
224
  var text = window.getSelection().toString();
218
225
  if (text != ''){
@@ -221,7 +228,7 @@
221
228
  $('.phrases-menu__block').addClass('hide');
222
229
  $matches.removeClass('hide');
223
230
  $('.phrases-menu__search').html('<u>Search</u>: ' + text);
224
-
231
+
225
232
  if($matches.length > 0){
226
233
  $('.phrases-menu').addClass('match-phrase');
227
234
  }else{
@@ -236,8 +243,20 @@
236
243
  }
237
244
  }
238
245
  $('*').mouseup(function() {
239
- searchSelectedText();
246
+ if(outPhrasesMenu){
247
+ searchSelectedText();
248
+ }
240
249
  });
250
+
251
+ $('#phrasesMenu').on('mouseenter', function(e){
252
+ console.log('#phrasesMenu', 'mouseenter');
253
+ outPhrasesMenu = false;
254
+ })
255
+
256
+ $('#phrasesMenu').on('mouseleave', function(e){
257
+ console.log('#phrasesMenu', 'mouseleave');
258
+ outPhrasesMenu = true;
259
+ })
241
260
  });
242
261
  function toggleNav() {
243
262
  document.getElementById("phrasesMenu").classList.toggle("open");
@@ -0,0 +1,12 @@
1
+ <div class="phrases-menu__block">
2
+ <div class="phrases-menu__key">
3
+ <%= phrase.code %>
4
+ </div>
5
+ <div class="phrases-menu__phrase">
6
+ <%= form_tag(rosetta.database_repository_phrase_path(id: phrase.code), method: :put, id: phrase.code) do %>
7
+ <%= hidden_field_tag(:current_path, url_for) %>
8
+ <%= text_area_tag(:value, phrase.text, id: "#{phrase.code}_value", class: 'database__field') %>
9
+ <%= submit_tag("Update", id: "#{phrase.code}_submit") %>
10
+ <% end %>
11
+ </div>
12
+ </div>
data/config/routes.rb CHANGED
@@ -1,2 +1,5 @@
1
- Rails.application.routes.draw do
1
+ Rosetta::Engine.routes.draw do
2
+ namespace :database_repository do
3
+ resources :phrases, constraints: { id: %r{[^\/]+} }, only: [:update]
4
+ end
2
5
  end
data/lib/rosetta.rb CHANGED
@@ -8,6 +8,7 @@ require 'rosetta/phrase'
8
8
  require 'rosetta/repository'
9
9
  require 'rosetta/controller_additions'
10
10
 
11
+ require 'rosetta/repositories/database'
11
12
  require 'rosetta/repositories/local'
12
13
  require 'rosetta/repositories/onesky'
13
14
 
@@ -0,0 +1,19 @@
1
+ module Rosetta
2
+ module Repositories
3
+ class Database < Rosetta::Repository
4
+
5
+ def id
6
+ 'database'
7
+ end
8
+
9
+ def label
10
+ 'Database'
11
+ end
12
+
13
+ def build_link(_keys, **_args)
14
+ ''
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Rosetta
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosetta
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MarsBased
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-03 00:00:00.000000000 Z
11
+ date: 2019-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: database_cleaner
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  description: Rosetta makes it easy for copy writers to edit the translations of your
154
168
  app.
155
169
  email:
@@ -164,7 +178,10 @@ files:
164
178
  - app/assets/config/rosetta_manifest.js
165
179
  - app/assets/images/rosetta/close.svg
166
180
  - app/assets/images/rosetta/language_icon.svg
181
+ - app/controllers/rosetta/base_controller.rb
182
+ - app/controllers/rosetta/database_repository/phrases_controller.rb
167
183
  - app/views/rosetta/_translate_menu.html.erb
184
+ - app/views/rosetta/database/_actions.html.erb
168
185
  - app/views/rosetta/local/_actions.html.erb
169
186
  - app/views/rosetta/onesky/_actions.html.erb
170
187
  - config/routes.rb
@@ -176,12 +193,13 @@ files:
176
193
  - lib/rosetta/engine.rb
177
194
  - lib/rosetta/i18n_with_stored_phrases.rb
178
195
  - lib/rosetta/phrase.rb
196
+ - lib/rosetta/repositories/database.rb
179
197
  - lib/rosetta/repositories/local.rb
180
198
  - lib/rosetta/repositories/onesky.rb
181
199
  - lib/rosetta/repositories/onesky/languages_ids.yml
182
200
  - lib/rosetta/repository.rb
183
201
  - lib/rosetta/version.rb
184
- homepage: https://github.com/MarsBased/rosetta
202
+ homepage: https://github.com/MarsBased/rosetta-gem
185
203
  licenses:
186
204
  - MIT
187
205
  metadata: {}
@@ -200,8 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
218
  - !ruby/object:Gem::Version
201
219
  version: '0'
202
220
  requirements: []
203
- rubyforge_project:
204
- rubygems_version: 2.7.7
221
+ rubygems_version: 3.0.1
205
222
  signing_key:
206
223
  specification_version: 4
207
224
  summary: Rosetta makes it easy for copy writers to edit the translations of your app.