Module: I18n::Translate::Processor
- Defined in:
- lib/i18n/processor/gettext.rb,
lib/i18n/processor/properties.rb,
lib/i18n/processor/gettext_strscan.rb,
lib/i18n/processor/yaml.rb,
lib/i18n/processor/ruby.rb,
lib/i18n/processor/ts.rb,
lib/i18n/processor.rb
Overview
vi: fenc=utf-8:expandtab:ts=2:sw=2:sts=2
@author: Petr Kovar <[email protected]>
Defined Under Namespace
Classes: Gettext, GettextScanner, Properties, Ruby, TS, Template, YAML
Class Attribute Summary collapse
-
.processors ⇒ Object
readonly
Returns the value of attribute processors.
Class Method Summary collapse
-
.<<(processor) ⇒ Object
append processor to the registry.
-
.find_processor(fname) ⇒ Object
find appropriate processor for given file name.
-
.init(default = 'yml') ⇒ Object
register formats from all known processors.
-
.read(fname, tr) ⇒ Object
find processor for fname and use it to read data.
-
.write(fname, data, tr) ⇒ Object
find processor for fname and use it to save data.
Class Attribute Details
.processors ⇒ Object (readonly)
Returns the value of attribute processors.
12 13 14 |
# File 'lib/i18n/processor.rb', line 12 def processors @processors end |
Class Method Details
.<<(processor) ⇒ Object
append processor to the registry
16 17 18 |
# File 'lib/i18n/processor.rb', line 16 def self.<<(processor) @processors << processor end |
.find_processor(fname) ⇒ Object
find appropriate processor for given file name
37 38 39 40 41 42 |
# File 'lib/i18n/processor.rb', line 37 def self.find_processor(fname) @processors.each do |processor| return processor if processor.can_handle?(fname) end nil end |
.init(default = 'yml') ⇒ Object
register formats from all known processors
45 46 47 48 49 |
# File 'lib/i18n/processor.rb', line 45 def self.init(default='yml') @processors.each do |processor| processor.register(default) end end |
.read(fname, tr) ⇒ Object
find processor for fname and use it to read data
21 22 23 24 25 26 |
# File 'lib/i18n/processor.rb', line 21 def self.read(fname, tr) processor = find_processor(fname) raise "Unknown file format" unless processor worker = processor.new(fname, tr) worker.read end |
.write(fname, data, tr) ⇒ Object
find processor for fname and use it to save data
29 30 31 32 33 34 |
# File 'lib/i18n/processor.rb', line 29 def self.write(fname, data, tr) processor = find_processor(fname) raise "Unknown file format `#{fname}'" unless processor worker = processor.new(fname, tr) worker.write(data) end |