Class: PhraseApp::InContextEditor::BackendService

Inherits:
Object
  • Object
show all
Defined in:
lib/phraseapp-in-context-editor-ruby/backend_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ BackendService

Returns a new instance of BackendService.



11
12
13
# File 'lib/phraseapp-in-context-editor-ruby/backend_service.rb', line 11

def initialize(args = {})
  self
end

Instance Attribute Details

#blacklisted_keys=(value) ⇒ Object

Sets the attribute blacklisted_keys

Parameters:

  • value

    the value to set the attribute blacklisted_keys to.



9
10
11
# File 'lib/phraseapp-in-context-editor-ruby/backend_service.rb', line 9

def blacklisted_keys=(value)
  @blacklisted_keys = value
end

Instance Method Details

#translate(*args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/phraseapp-in-context-editor-ruby/backend_service.rb', line 15

def translate(*args)
  if to_be_translated_without_phraseapp?(args)
    # *Ruby 2.7+ keyword arguments warning*
    #
    # This method uses keyword arguments.
    # There is a breaking change in ruby that produces warning with ruby 2.7 and won't work as expected with ruby 3.0
    # The "hash" parameter must be passed as keyword argument.
    #
    # Good:
    #  I18n.t(:salutation, :gender => 'w', :name => 'Smith')
    #  I18n.t(:salutation, **{ :gender => 'w', :name => 'Smith' })
    #  I18n.t(:salutation, **any_hash)
    #
    # Bad:
    #  I18n.t(:salutation, { :gender => 'w', :name => 'Smith' })
    #  I18n.t(:salutation, any_hash)
    #
    kw_args = args[1]
    if kw_args.present?
      I18n.translate_without_phraseapp(args[0], **kw_args)
    else
      I18n.translate_without_phraseapp(args[0])
    end
  else
    phraseapp_delegate_for(args)
  end
end