Module: Lit::CloudTranslation
- Defined in:
- lib/lit/cloud_translation.rb
Defined Under Namespace
Modules: Providers Classes: TranslationError
Class Method Summary collapse
-
.configure(&block) ⇒ Object
Optional if provider-speciffic environment variables are set correctly.
-
.provider ⇒ Object
Returns the currently active cloud translation provider, descending from Lit::CloudTranslation::Providers::Base.
-
.provider=(provider) ⇒ Object
Sets the provider for cloud translations.
-
.translate(text:, from: nil, to:, **opts) ⇒ Object
Uses the active translation provider to translate a text or array of texts.
Class Method Details
.configure(&block) ⇒ Object
Optional if provider-speciffic environment variables are set correctly. Configures the cloud translation provider with specific settings, overriding those from environment if needed.
42 43 44 45 46 47 48 49 50 |
# File 'lib/lit/cloud_translation.rb', line 42 def configure(&block) unless provider raise 'Translation provider not selected yet. Use `Lit::CloudTranslation' \ '.provider = PROVIDER_KLASS` before calling #configure.' end provider.tap do |p| p.configure(&block) end end |
.provider ⇒ Object
Returns the currently active cloud translation provider, descending from Lit::CloudTranslation::Providers::Base.
18 19 20 |
# File 'lib/lit/cloud_translation.rb', line 18 def provider @provider end |
.provider=(provider) ⇒ Object
Sets the provider for cloud translations.
12 13 14 |
# File 'lib/lit/cloud_translation.rb', line 12 def provider=(provider) @provider = provider end |
.translate(text:, from: nil, to:, **opts) ⇒ Object
Uses the active translation provider to translate a text or array of texts.
29 30 31 |
# File 'lib/lit/cloud_translation.rb', line 29 def translate(text:, from: nil, to:, **opts) provider.translate(text: text, from: from, to: to, **opts) end |