Sha256: de7cad46a9f8a365408d160895713798833f4de397774d5039446f087f8c9932
Contents?: true
Size: 755 Bytes
Versions: 3
Compression:
Stored size: 755 Bytes
Contents
require 'bing_translator' class AutoTranslator def initialize parameters = { original: nil, to: nil } @translator = nil @translation = nil @original = parameters[:original] @to = parameters[:to] end def perform set_translator raw_translate fix_special_characters @translation end private def set_translator @translator = BingTranslator.new( Autotolk.bing_client_id, Autotolk.bing_client_secret, false, Autotolk.azure_account_key) end def raw_translate @translation = @translator.translate @original, to: @to end def fix_special_characters @translation.gsub!('% {', '%{') @translation.gsub!(/{(?<word>\w+)} %[^{]*/, '%{\k<word>}') @translation.gsub!('---', '') end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
autotolk-0.1.5 | app/services/auto_translator.rb |
autotolk-0.1.4 | app/services/auto_translator.rb |
autotolk-0.1.2 | app/services/auto_translator.rb |