Plugin and YAML configuration file

Hello,

Using an external YAML file for storing static datas is cool. And doing
so in a basic Rails application is easy using in
config/initializers/load_config.rb such:
CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")
...after what datas can be called in application.rb with
CONFIG['something'].

But how can we load the YAML configuration file of a plugin (in its
controller for instance)? For example if my plugin is in
vendor/plugins/my_plugin and its YAML file is in
vendor/plugins/my_plugin/config.yml?

Well you can have your plugin's code do anything you want, including
read in such a yaml file if you want.

And I have an other question about this topic: is that possible to

complet the Rails internationalization's YAML files stored in
config/locales/ using a additionnal YAML file into the plugin (in order
to generate dynamic flash messages for instance in plugin's controllers,
like so: flash[:error] = t(there_is_an_error))?

You could try adding the appropriate folder(s) to the i18n load path.

Fred

Thank you for your answer, Frederick.

Is there an example of plugin using those mechanisms?

Thank you for your answer, Frederick.

Is there an example of plugin using those mechanisms?

Not that I've seen, but then I haven't looked. The rails I18n guide
probably discusses the i18n load path stuff and the configuration
stuff should be straight forward - loading some yaml and assigning it
to a constant isn't going to be radically different just because a
plugin is involved.

Fred