Parent

R18n::TranslatedString

String, which is translated to some locale and loading from Translation.

Attributes

locale[R]

String locale

path[R]

Path for this translation.

Public Class Methods

_load(str) click to toggle source

Load object from Marshalizing.

# File lib/r18n-core/translated_string.rb, line 68
def self._load(str)
  arr = str.split(":", 3)
  new arr[2], R18n.locale(arr[0]), arr[1]
end
new(str, locale, path, filters = nil) click to toggle source

Returns a new string object containing a copy of str, which translated for path to locale

# File lib/r18n-core/translated_string.rb, line 31
def initialize(str, locale, path, filters = nil)
  super(str)
  @filters = filters
  @locale  = locale
  @path    = path
end

Public Instance Methods

_dump(limit) click to toggle source

Override marshal_dump to avoid Marshalizing filter procs

# File lib/r18n-core/translated_string.rb, line 63
def _dump(limit)
  [@locale.code, @path, to_str].join(":")
end
get_untranslated(key) click to toggle source

Return untranslated for deeper node `key`. It is in separated methods to be used in R18n I18n backend.

# File lib/r18n-core/translated_string.rb, line 75
def get_untranslated(key)
  translated = @path.empty? ? '' : "#{@path}."
  Untranslated.new(translated, key, @locale, @filters)
end
html_safe?() click to toggle source

Mark translated string as html safe, because R18n has own escape system.

# File lib/r18n-core/translated_string.rb, line 49
def html_safe?
  true
end
method_missing(name, *params) click to toggle source

Return untranslated, when user try to go deeper in translation.

# File lib/r18n-core/translated_string.rb, line 81
def method_missing(name, *params)
  get_untranslated(name.to_s)
end
to_s() click to toggle source

Override to_s to make string html safe if `html_safe` method is defined.

# File lib/r18n-core/translated_string.rb, line 54
def to_s
  if respond_to? :html_safe
    html_safe
  else
    String.new(self)
  end
end
translated?() click to toggle source

Return true for translated strings.

# File lib/r18n-core/translated_string.rb, line 44
def translated?
  true
end
|(default) click to toggle source

Return self for translated string.

# File lib/r18n-core/translated_string.rb, line 39
def |(default)
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.