Add MicrososftTranslateClient to new namespace

- Rename to Client
- Add to new namespace RemoteTranslations::Microsoft
- Update references to new namespace
This commit is contained in:
taitus
2019-05-24 15:13:15 +02:00
committed by voodoorai2000
parent 91ba5ff879
commit d29656d78f
5 changed files with 35 additions and 35 deletions

View File

@@ -2,7 +2,7 @@ require "translator-text"
include SentencesParser
include RemoteAvailableLocales
class MicrosoftTranslateClient
class RemoteTranslations::Microsoft::Client
CHARACTERS_LIMIT_PER_REQUEST = 5000
PREVENTING_TRANSLATION_KEY = "notranslate"

View File

@@ -35,7 +35,7 @@ class RemoteTranslationsCaller
end
def translations
@translations ||= MicrosoftTranslateClient.new.call(fields_values, locale)
@translations ||= RemoteTranslations::Microsoft::Client.new.call(fields_values, locale)
end
def fields_values

View File

@@ -1,7 +1,7 @@
module SentencesParser
def detect_split_position(text)
minimum_valid_index = text.size - MicrosoftTranslateClient::CHARACTERS_LIMIT_PER_REQUEST
minimum_valid_index = text.size - RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST
valid_point = text[minimum_valid_index..text.size].index(".")
valid_whitespace = text[minimum_valid_index..text.size].index(" ")