Class: Translatomatic::Provider::Microsoft

Inherits:
Base
  • Object
show all
Defined in:
lib/translatomatic/provider/microsoft.rb

Overview

Interface to the Microsoft translation API

Instance Attribute Summary

Attributes inherited from Base

#listener

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#name, #to_s, #translate

Constructor Details

#initialize(options = {}) ⇒ Microsoft

Create a new Microsoft provider instance



23
24
25
26
27
# File 'lib/translatomatic/provider/microsoft.rb', line 23

def initialize(options = {})
  super(options)
  @key = options[:microsoft_api_key] || ENV['MICROSOFT_API_KEY']
  raise t('provider.microsoft.key_required') if @key.nil?
end

Class Method Details

.supports_alternative_translations?boolean

Returns True if a string can have alternative translations.

Returns:

  • (boolean)

    True if a string can have alternative translations



13
14
15
# File 'lib/translatomatic/provider/microsoft.rb', line 13

def self.supports_alternative_translations?
  true
end

.supports_no_translate_html?boolean

Returns true if this provider supports html5 <span translate=“no”></span> tags.

Returns:

  • (boolean)

    true if this provider supports html5 <span translate=“no”></span> tags.



18
19
20
# File 'lib/translatomatic/provider/microsoft.rb', line 18

def self.supports_no_translate_html?
  true
end

Instance Method Details

#languagesArray<String>

Returns A list of languages supported by this provider.

Returns:

  • (Array<String>)

    A list of languages supported by this provider.



30
31
32
# File 'lib/translatomatic/provider/microsoft.rb', line 30

def languages
  @languages ||= fetch_languages
end