Class: R18n::UnsupportedLocale

Inherits:
Object
  • Object
show all
Defined in:
lib/r18n-core/unsupported_locale.rb

Overview

Locale without information file. Contain only it code, empty title and data from default locale.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, _base = nil) ⇒ UnsupportedLocale

Create object for unsupported locale with code and load other locale data from base locale.



29
30
31
32
# File 'lib/r18n-core/unsupported_locale.rb', line 29

def initialize(code, _base = nil)
  @code = code
  @base = Locale.load(I18n.default) if @code != I18n.default
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *params) ⇒ Object

Proxy to default locale object.



58
59
60
# File 'lib/r18n-core/unsupported_locale.rb', line 58

def method_missing(name, *params)
  @base.send(name, *params)
end

Instance Attribute Details

#baseObject

Locale, to get data and pluralization for unsupported locale.



25
26
27
# File 'lib/r18n-core/unsupported_locale.rb', line 25

def base
  @base
end

#codeObject (readonly)

Locale RFC 3066 code.



45
46
47
# File 'lib/r18n-core/unsupported_locale.rb', line 45

def code
  @code
end

Instance Method Details

#==(other) ⇒ Object

Is another locale has same code.



53
54
55
# File 'lib/r18n-core/unsupported_locale.rb', line 53

def ==(other)
  @code.casecmp(other.code).zero?
end

#inspectObject

Human readable locale code and title.



40
41
42
# File 'lib/r18n-core/unsupported_locale.rb', line 40

def inspect
  "Unsupported locale #{@code}"
end

#supported?Boolean

Is locale has information file. In this class always return false.

Returns:

  • (Boolean)


35
36
37
# File 'lib/r18n-core/unsupported_locale.rb', line 35

def supported?
  false
end

#titleObject

Locale code as title.



48
49
50
# File 'lib/r18n-core/unsupported_locale.rb', line 48

def title
  @code
end