Parent

R18n::Untranslated

Return if translation isn’t exists. Unlike nil, it didn’t raise error when you try to access for subtranslations.

You can set format to print untranslated string by filters. For example: Disable standart output:

R18n::Filters.off(:untranslated)

For development environment:

R18n::Filters.add(R18n::Untranslated, :untranslated_html) do
  |content, config, translated_path, untranslated_path, path|
  "#{translated_path}<span style='color: red'>#{untranslated_path}</span>"
end

For production environment:

R18n::Filters.add(R18n::Untranslated, :hide_untranslated) { '' }

Attributes

locale[R]

Main locale, where string was try to find

translated_path[R]

Path, that exists in translation.

untranslated_path[R]

Path, that isn’t in translation.

Public Class Methods

_load(str) click to toggle source

Load object from Marshalizing.

# File lib/r18n-core/untranslated.rb, line 71
def self._load(str)
  arr = str.split(":", 3)
  new arr[1], arr[2], R18n.locale(arr[0]), GlobalFilterList.instance
end
new(translated_path, untranslated_path, locale, filters) click to toggle source
# File lib/r18n-core/untranslated.rb, line 49
def initialize(translated_path, untranslated_path, locale, filters)
  @translated_path   = translated_path
  @untranslated_path = untranslated_path
  @locale            = locale
  @filters           = filters
end

Public Instance Methods

==(untrsl) click to toggle source

Is another locale has same code.

# File lib/r18n-core/untranslated.rb, line 102
def ==(untrsl)
  return false unless untrsl.is_a? Untranslated
  return false unless locale            == untrsl.locale
  return false unless translated_path   == untrsl.translated_path
  return false unless untranslated_path == untrsl.untranslated_path
  true
end
[](*params) click to toggle source
# File lib/r18n-core/untranslated.rb, line 85
def [](*params)
  Untranslated.new(translated_path, "#{@untranslated_path}.#{params.first}",
                   @locale, @filters)
end
_dump(limit) click to toggle source

Override marshal_dump to avoid Marshalizing filter procs

# File lib/r18n-core/untranslated.rb, line 66
def _dump(limit)
  [@locale.code, @translated_path, @untranslated_path].join(":")
end
method_missing(name, *params) click to toggle source
# File lib/r18n-core/untranslated.rb, line 76
def method_missing(name, *params)
  # It is need to fix some hack in specs
  if name == :to_ary
    raise NoMethodError, "undefined method `to_ary' for #{to_s}"
  end

  self[name]
end
path() click to toggle source

Path to translation.

# File lib/r18n-core/untranslated.rb, line 57
def path
  "#{@translated_path}#{@untranslated_path}"
end
to_s() click to toggle source
# File lib/r18n-core/untranslated.rb, line 94
def to_s
  @filters.process(:all, Untranslated, path, @locale, path,
                  [@translated_path, @untranslated_path, path])
end
Also aliased as: to_str
to_str() click to toggle source
Alias for: to_s
translated?() click to toggle source
# File lib/r18n-core/untranslated.rb, line 61
def translated?
  false
end
|(default) click to toggle source
# File lib/r18n-core/untranslated.rb, line 90
def |(default)
  default
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.