Module: Merb::Global::MessageProviders::Base
- Included in:
- ActiveRecord, Gettext, Mock, Sequel, Yaml
- Defined in:
- lib/merb_global/message_providers.rb
Overview
Merb-global is able to store the translations in different types of storage. An interface between merb_global and those storages are providers.
Please note that it is not required to include this module - despite it is recomended both as a documentation part and the more customized error messages.
Defined Under Namespace
Class Method Summary collapse
-
.transfer(importer, exporter) ⇒ Object
Transfer data from importer into exporter.
Instance Method Summary collapse
-
#create! ⇒ Object
This method creates basic files and/or directory structures (for example it adds migration) needed for provider to work.
-
#localize(singular, plural, n, locale) ⇒ Object
call-seq: localize(singular, plural, opts) => translated.
Class Method Details
.transfer(importer, exporter) ⇒ Object
Transfer data from importer into exporter
Parameters
- importer<Importer>
-
The provider providing the information
- exporter<Exporter>
-
The provider receiving the information
77 78 79 |
# File 'lib/merb_global/message_providers.rb', line 77 def self.transfer(importer, exporter) exporter.export importer.import end |
Instance Method Details
#create! ⇒ Object
This method creates basic files and/or directory structures (for example it adds migration) needed for provider to work.
It is called from Rakefile.
68 69 70 |
# File 'lib/merb_global/message_providers.rb', line 68 def create! raise NoMethodError.new('method create! has not been implemented') end |
#localize(singular, plural, n, locale) ⇒ Object
call-seq:
localize(singular, plural, opts) => translated
Translate string using specific provider. It should be overloaded by the implementor.
Do not use this method directly - use Merb::Global._ instead
Parameters
- singular<String>
-
A string to translate
- plural<String>
-
A plural form of string (nil if only singular)
- n<Fixnum>
-
A number of objects
- locale<Locale>
-
A locale to which translate
Returns
- translated<String>
-
A translated string
Raises
- NoMethodError
-
Raised by default implementation. Should not be thrown.
61 62 63 |
# File 'lib/merb_global/message_providers.rb', line 61 def localize(singular, plural, n, locale) raise NoMethodError.new 'method localize has not been implemented' end |