Module: Rosette::Core::Commands::WithLocale

Included in:
ExportCommand, TranslationLookupCommand
Defined in:
lib/rosette/core/commands/translations/with_locale.rb

Overview

Mixin that handles configuration and validation of a locale code. Meant to be mixed into the classes in Rosette::Core::Commands.

Examples:

class MyCommand < Command
  include WithRepoName
  include WithLocale
end

cmd = MyCommand.new(configuration)
  .set_repo_name('my_repo')
  .set_locale('ja-JP')

cmd.locale    # => 'ja-JP'
cmd.valid?    # => true

cmd.set_locale('foobar')
cmd.valid?    # => false
cmd.messages  # => { locale: ["Repo 'my_repo' doesn't support the 'foobar' locale"] }

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#localeObject (readonly)

Returns the value of attribute locale


27
28
29
# File 'lib/rosette/core/commands/translations/with_locale.rb', line 27

def locale
  @locale
end

Instance Method Details

#set_locale(locale_code) ⇒ self

Sets the locale code.


33
34
35
36
# File 'lib/rosette/core/commands/translations/with_locale.rb', line 33

def set_locale(locale_code)
  @locale = locale_code
  self
end