autotolk 0.1.2 → 0.1.3

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: 99ba99954c85978aed16ebf0967290cbbc67374c
4
- data.tar.gz: f85a3b070fdbbf171d6190b2434ff6e0a4170b1f
3
+ metadata.gz: dbc8e5491bd9094856a5d8dff1c5d22380abf650
4
+ data.tar.gz: 3136eeae2d1d52f4dfc7165e4deed7a98d157a87
5
5
  SHA512:
6
- metadata.gz: 7072bd5e147ca11b3d1ce68b74a06b63388f4a3c3ef6fa9fd8346523d3591c373d1f3e26287882149acacc3297bf4b6d9156bb78c68263c730f4bc38940060c4
7
- data.tar.gz: 67b3a1afb4a1a07aed7659c7f20eb371b5d168e7c6b4364905ceab37b466c0e209adeb74539bfc9628489f4db44c49ca72e284f0dadb32877a34977811ec6868
6
+ metadata.gz: 5588876696258d52df1b5645e12ffc5bde967139a51f10805c8d29e0fffa7f5af07f7a67085fe3daa1bbb49857b4cad9e8c6e73118472c8d7361b69a25edf64b
7
+ data.tar.gz: b9bfa064f322bcc44891776a98770d5ab0e16cb35b536d418a8491eec3be66c2feb75afb77e19f6f0edce709680baed35229d10015e535216880a8b56663b8d9
data/README.md CHANGED
@@ -26,7 +26,7 @@ And follow the instructions on the screen (you will have to add your bing tokens
26
26
 
27
27
  ## Usage
28
28
 
29
- Now when you go to `/tolk/locales/xx` you will see a button `Start autotranslating!`. When you click on it, the translation will be automatic. The text areas will fill out with the translated text, so you could change it if needed and save.
29
+ Now when you go to `/tolk/locales/xx` you will see an alert informing you that when you double click anywhere, the translation will be automatic. The text areas will fill out with the translated text, so you could change it if needed and save.
30
30
 
31
31
  ## Issues
32
32
 
@@ -1,8 +1,12 @@
1
+ require 'bing_translator'
2
+
1
3
  class TranslationsController < ApplicationController
2
4
  skip_before_action :authenticate_user!, :validate_subdomain
3
5
 
4
6
  def translate
5
- translated = AutoTranslator.new(original: params[:original], to: params[:to]).perform
7
+ translator = BingTranslator.new( Autotolk.bing_client_id, Autotolk.bing_client_secret,
8
+ false, Autotolk.azure_account_key)
9
+ translated = translator.translate params[:original], :to => params[:to]
6
10
  render json: {status: 200, translated: translated}
7
11
  rescue Exception => e
8
12
  render json: {status: 500, error: e}
@@ -1,3 +1,3 @@
1
1
  module Autotolk
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autotolk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Rajewska
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,7 +71,6 @@ files:
71
71
  - app/assets/javascripts/.DS_Store
72
72
  - app/assets/javascripts/autotolk/locales.js.coffee
73
73
  - app/controllers/translations_controller.rb
74
- - app/services/auto_translator.rb
75
74
  - autotolk.gemspec
76
75
  - bin/console
77
76
  - bin/setup
@@ -1,35 +0,0 @@
1
- require 'bing_translator'
2
-
3
- class AutoTranslator
4
-
5
- def initialize parameters = { original: nil, to: nil }
6
- @translator = nil
7
- @translation = nil
8
- @original = parameters[:original]
9
- @to = parameters[:to]
10
- end
11
-
12
- def perform
13
- set_translator
14
- raw_translate
15
- fix_special_characters
16
- @translation
17
- end
18
-
19
- private
20
-
21
- def set_translator
22
- @translator = BingTranslator.new( Autotolk.bing_client_id, Autotolk.bing_client_secret,
23
- false, Autotolk.azure_account_key)
24
- end
25
-
26
- def raw_translate
27
- @translation = @translator.translate @original, to: @to
28
- end
29
-
30
- def fix_special_characters
31
- @translation.gsub!('% {', '%{')
32
- @translation.gsub!(/{(?<word>\w+)} %[^{]*/, '%{\k<word>}')
33
- @translation.gsub!('---', '')
34
- end
35
- end