Module: TranslationDiff
- Defined in:
- lib/translation_diff/errors.rb,
lib/translation_diff.rb,
lib/translation_diff/version.rb
Overview
No error carries the text being translated -- errors are logged, and this library handles other people's content.
Defined Under Namespace
Modules: ActiveRecord, CallPreparation, Instrumentation, Languages, Leaves, Markup, Providers, RateLimiters, Redaction, Segmenters, Stores, Translation Classes: AuthenticationError, Batch, Capabilities, Configuration, ConfigurationError, Context, Dispatcher, Document, Error, Fragment, HTTPProvider, InstallGenerator, InvalidProviderError, InvalidRequestError, Passage, Preview, Previewer, Provider, ProviderError, QuotaExceededError, Railtie, RateLimitError, RateLimitExceeded, Registry, ResponseError, Segment, SentenceCache, ServiceError, Translator, TransportError, UnsupportedLanguageError
Constant Summary collapse
- VERSION =
"1.0.0".freeze
Class Method Summary collapse
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
-
.context ⇒ Object
An isolated copy of the configuration with the same entry point, for per-tenant settings.
-
.preview(values, from: nil, to: nil, provider: nil, assume_supported: false) ⇒ Object
Answers what
translatewould do tovalues, without calling a provider or writing anything. -
.reset! ⇒ Object
Without this, one test's configuration leaks into every test that runs after it.
-
.translate(values, from: nil, to: nil, provider: nil, assume_supported: false) ⇒ Object
provider:,config:andassume_supported:are reserved; every other keyword is forwarded to the provider.
Class Method Details
.config ⇒ Object
71 |
# File 'lib/translation_diff.rb', line 71 def config = @config ||= Configuration.new |
.configure {|config| ... } ⇒ Object
73 |
# File 'lib/translation_diff.rb', line 73 def configure = yield(config) |
.context ⇒ Object
An isolated copy of the configuration with the same entry point, for per-tenant settings.
79 |
# File 'lib/translation_diff.rb', line 79 def context(&) = Context.new(config.copy.tap(&)) |
.preview(values, from: nil, to: nil, provider: nil, assume_supported: false) ⇒ Object
Answers what translate would do to values, without calling a provider or writing anything.
88 89 90 91 |
# File 'lib/translation_diff.rb', line 88 def preview(values, from: nil, to: nil, provider: nil, assume_supported: false, **) Previewer.new(values, from: from, to: to, provider: provider, config: config, assume_supported: assume_supported, **).call end |
.reset! ⇒ Object
Without this, one test's configuration leaks into every test that runs after it.
76 |
# File 'lib/translation_diff.rb', line 76 def reset! = @config = nil |
.translate(values, from: nil, to: nil, provider: nil, assume_supported: false) ⇒ Object
provider:, config: and assume_supported: are reserved; every other keyword is forwarded to the provider.
82 83 84 85 |
# File 'lib/translation_diff.rb', line 82 def translate(values, from: nil, to: nil, provider: nil, assume_supported: false, **) Translator.new(values, from: from, to: to, provider: provider, config: config, assume_supported: assume_supported, **).call end |