Fix houncibot offenses.
This commit is contained in:
@@ -24,22 +24,22 @@ module RemoteTranslations::Microsoft::AvailableLocales
|
||||
|
||||
private
|
||||
|
||||
def remote_available_locales
|
||||
host = "https://api.cognitive.microsofttranslator.com"
|
||||
path = "/languages?api-version=3.0"
|
||||
def remote_available_locales
|
||||
host = "https://api.cognitive.microsofttranslator.com"
|
||||
path = "/languages?api-version=3.0"
|
||||
|
||||
uri = URI (host + path)
|
||||
uri = URI (host + path)
|
||||
|
||||
request = Net::HTTP::Get.new(uri)
|
||||
request["Ocp-Apim-Subscription-Key"] = Rails.application.secrets.microsoft_api_key
|
||||
request = Net::HTTP::Get.new(uri)
|
||||
request["Ocp-Apim-Subscription-Key"] = Rails.application.secrets.microsoft_api_key
|
||||
|
||||
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == "https") do |http|
|
||||
http.request (request)
|
||||
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == "https") do |http|
|
||||
http.request (request)
|
||||
end
|
||||
|
||||
result = response.body.force_encoding("utf-8")
|
||||
|
||||
JSON.parse(result)["translation"]
|
||||
end
|
||||
|
||||
result = response.body.force_encoding("utf-8")
|
||||
|
||||
JSON.parse(result)["translation"]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
module RemoteTranslations::Microsoft::SentencesParser
|
||||
|
||||
def detect_split_position(text)
|
||||
minimum_valid_index = text.size - RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST
|
||||
limit = RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST
|
||||
minimum_valid_index = text.size - limit
|
||||
valid_point = text[minimum_valid_index..text.size].index(".")
|
||||
valid_whitespace = text[minimum_valid_index..text.size].index(" ")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user