autotolk 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +1 -1
- data/app/controllers/translations_controller.rb +5 -1
- data/lib/autotolk/version.rb +1 -1
- metadata +2 -3
- data/app/services/auto_translator.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbc8e5491bd9094856a5d8dff1c5d22380abf650
|
4
|
+
data.tar.gz: 3136eeae2d1d52f4dfc7165e4deed7a98d157a87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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}
|
data/lib/autotolk/version.rb
CHANGED
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.
|
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-
|
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
|